Skip to content

Commit

Permalink
ensure compressed file header accounts for overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ybirader committed Sep 6, 2023
1 parent 1fa8d1d commit 9c31929
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion archiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (a *Archiver) populateHeader(file *pool.File) error {
} else {
header.Method = zip.Deflate
header.Flags |= 0x8 // will write data descriptor (crc32, comp, uncomp)
header.CompressedSize64 = uint64(file.CompressedData.Len())
header.CompressedSize64 = uint64(file.Written())
}

file.Header = header
Expand Down
1 change: 1 addition & 0 deletions archiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func TestCompress(t *testing.T) {
assert.Equal(t, file.CompressedData.Len(), bufCap)
assert.Equal(t, pool.FileFull, file.Status)
assertGreaterThan(t, file.Written(), int64(file.CompressedData.Len()))
assert.Equal(t, file.Written(), int64(file.Header.CompressedSize64))

assert.NotZero(t, file.Overflow)
overflowInfo := testutils.GetFileInfo(t, file.Overflow.Name())
Expand Down

0 comments on commit 9c31929

Please sign in to comment.