From 459343932d9673fc69ce1363ccb70d5f78f2e3e7 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Thu, 7 Oct 2021 11:56:37 +0200 Subject: fix storeDelta by keeping previous raw bytes this ensures that the last patch is created on top of the previous one. This way we know that it will be correctly applied on loadDelta Also directly write to wrapper instead of using an intermediate buffer. --- delta/delta.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'delta') diff --git a/delta/delta.go b/delta/delta.go index 439da1d..4be57c2 100644 --- a/delta/delta.go +++ b/delta/delta.go @@ -1,6 +1,7 @@ package delta import ( + "fmt" "io" "github.com/gabstv/go-bsdiff/pkg/bsdiff" @@ -44,15 +45,15 @@ func (Fdelta) Diff(source io.Reader, target io.Reader, patch io.Writer) error { func (Fdelta) Patch(source io.Reader, target io.Writer, patch io.Reader) error { sourceBuf, err := io.ReadAll(source) if err != nil { - return err + return fmt.Errorf("source read all: %s", err) } patchBuf, err := io.ReadAll(patch) if err != nil { - return err + return fmt.Errorf("patch read all: %s", err) } targetBuf, err := fdelta.Apply(sourceBuf, patchBuf) if err != nil { - return err + return fmt.Errorf("apply patch: %s", err) } _, err = target.Write(targetBuf) return err -- cgit v1.2.3