diff options
author | n-peugnet <n.peugnet@free.fr> | 2021-10-07 11:56:37 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2021-10-07 11:56:37 +0200 |
commit | 459343932d9673fc69ce1363ccb70d5f78f2e3e7 (patch) | |
tree | 29514fb9a369d023a7c797bea75aeefe715d7ca5 /delta/delta.go | |
parent | 5be8ba4dff6c181fd78b5922be27c599c6b8d842 (diff) | |
download | dna-backup-459343932d9673fc69ce1363ccb70d5f78f2e3e7.tar.gz dna-backup-459343932d9673fc69ce1363ccb70d5f78f2e3e7.zip |
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.
Diffstat (limited to 'delta/delta.go')
-rw-r--r-- | delta/delta.go | 7 |
1 files changed, 4 insertions, 3 deletions
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 |