diff --git a/archiver_test.go b/archiver_test.go index 899caca..87e4d55 100644 --- a/archiver_test.go +++ b/archiver_test.go @@ -140,11 +140,11 @@ func TestCompress(t *testing.T) { assert.NotZero(t, file.Header.CRC32) assert.Equal(t, uint64(info.Size()), file.Header.UncompressedSize64) assert.Equal(t, uint64(file.CompressedData.Len()), file.Header.CompressedSize64) - assert.Equal(t, file.CompressedData.Len(), file.Written()) + assert.Equal(t, int64(file.CompressedData.Len()), file.Written()) assertExtendedTimestamp(t, file.Header.Extra) }) - t.Run("writes a maximum of buffer cap bytes", func(t *testing.T) { + t.Run("writes a maximum of buffer cap bytes and remainder directly to archived file", func(t *testing.T) { archive, cleanup := testutils.CreateTempArchive(t, archivePath) defer cleanup() @@ -162,7 +162,7 @@ func TestCompress(t *testing.T) { assert.Equal(t, file.CompressedData.Len(), bufCap) assert.Equal(t, pool.FileFull, file.Status) - assert.Equal(t, file.CompressedData.Len(), file.Written()) + assert.Equal(t, int64(file.CompressedData.Len()), file.Written()) }) t.Run("for directories", func(t *testing.T) { @@ -186,7 +186,7 @@ func TestCompress(t *testing.T) { assert.Zero(t, file.Header.CRC32) assert.Equal(t, 0, file.Header.UncompressedSize64) assert.Equal(t, 0, file.Header.CompressedSize64) - assert.Equal(t, file.CompressedData.Len(), file.Written()) + assert.Equal(t, int64(file.CompressedData.Len()), file.Written()) }) } diff --git a/pool/file.go b/pool/file.go index 18eacfe..a97a9da 100644 --- a/pool/file.go +++ b/pool/file.go @@ -17,7 +17,7 @@ type File struct { CompressedData bytes.Buffer Header *zip.FileHeader Status Status - written int + written int64 } type Status int @@ -44,7 +44,7 @@ func NewFile(path string, info fs.FileInfo, relativeTo string) (File, error) { func (f *File) Write(p []byte) (n int, err error) { if f.CompressedData.Available() != 0 { maxWritable := min(f.CompressedData.Available(), len(p)) - f.written += maxWritable + f.written += int64(maxWritable) return f.CompressedData.Write(p[:int(maxWritable)]) } @@ -52,7 +52,7 @@ func (f *File) Write(p []byte) (n int, err error) { return len(p), nil } -func (f *File) Written() int { +func (f *File) Written() int64 { return f.written }