1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 07:43:03 +00:00

Merge pull request #5054 from phillipp/dump-compress-zip

dump: add --compress flag to compress archives
This commit is contained in:
Michael Eischer 2024-10-16 19:17:47 +00:00 committed by GitHub
commit 618f306f13
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -39,6 +39,9 @@ func (d *Dumper) dumpNodeZip(ctx context.Context, node *restic.Node, zw *zip.Wri
Modified: node.ModTime, Modified: node.ModTime,
} }
header.SetMode(node.Mode) header.SetMode(node.Mode)
if node.Type == restic.NodeTypeFile {
header.Method = zip.Deflate
}
if node.Type == restic.NodeTypeDir { if node.Type == restic.NodeTypeDir {
header.Name += "/" header.Name += "/"

View file

@ -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) return fmt.Errorf("symlink target does not match, got %s want %s", string(linkName), target)
} }
default: 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 { if uint64(match.Size()) != f.UncompressedSize64 {
return fmt.Errorf("size does not match got %v want %v", f.UncompressedSize64, match.Size()) return fmt.Errorf("size does not match got %v want %v", f.UncompressedSize64, match.Size())
} }