diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2023-12-31 21:40:55 -0700 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2023-12-31 21:40:55 -0700 |
commit | a17ff9e9db5ecf20542a69654ade63d9f3aa7220 (patch) | |
tree | 76693d1dfbab838d7787c61a51978e5ea5758fcb /lib/diskio | |
parent | 8f681540e079a70632bbc11deb3f122c5ba348cd (diff) |
file_blockbuf.go: Ensure the cache is flushed before closing
Diffstat (limited to 'lib/diskio')
-rw-r--r-- | lib/diskio/file_blockbuf.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/diskio/file_blockbuf.go b/lib/diskio/file_blockbuf.go index 8c0fec2..002b40a 100644 --- a/lib/diskio/file_blockbuf.go +++ b/lib/diskio/file_blockbuf.go @@ -68,12 +68,16 @@ func (src bufferedBlockSource[A]) Load(ctx context.Context, blockAddr A, block * func (bf *bufferedFile[A]) Name() string { return bf.inner.Name() } func (bf *bufferedFile[A]) Size() A { return bf.inner.Size() } -func (bf *bufferedFile[A]) Close() error { return bf.inner.Close() } func (bf *bufferedFile[A]) Flush() { bf.blockCache.Flush(bf.ctx) } +func (bf *bufferedFile[A]) Close() error { + bf.Flush() + return bf.inner.Close() +} + func (bf *bufferedFile[A]) ReadAt(dat []byte, off A) (n int, err error) { done := 0 for done < len(dat) { |