diff --git a/changelog/unreleased/pull-5054 b/changelog/unreleased/pull-5054 new file mode 100644 index 000000000..6efd5882c --- /dev/null +++ b/changelog/unreleased/pull-5054 @@ -0,0 +1,7 @@ +Enhancement: Compress ZIP archives created by `dump` command + +Restic did not compress the archives that were created by using +the `dump` command. It now saves some disk space when exporting +archives using the DEFLATE algorithm for "zip" archives. + +https://github.com/restic/restic/pull/5054 diff --git a/internal/dump/zip.go b/internal/dump/zip.go index d32475770..17aeb4829 100644 --- a/internal/dump/zip.go +++ b/internal/dump/zip.go @@ -39,6 +39,9 @@ func (d *Dumper) dumpNodeZip(ctx context.Context, node *restic.Node, zw *zip.Wri Modified: node.ModTime, } header.SetMode(node.Mode) + if node.Type == restic.NodeTypeFile { + header.Method = zip.Deflate + } if node.Type == restic.NodeTypeDir { header.Name += "/" diff --git a/internal/dump/zip_test.go b/internal/dump/zip_test.go index 6f5f60f54..c6eb04206 100644 --- a/internal/dump/zip_test.go +++ b/internal/dump/zip_test.go @@ -101,6 +101,9 @@ func checkZip(t *testing.T, testDir string, srcZip *bytes.Buffer) error { return fmt.Errorf("symlink target does not match, got %s want %s", string(linkName), target) } default: + if f.Method != zip.Deflate { + return fmt.Errorf("expected compression method got %v want %v", f.Method, zip.Deflate) + } if uint64(match.Size()) != f.UncompressedSize64 { return fmt.Errorf("size does not match got %v want %v", f.UncompressedSize64, match.Size()) }