summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2023-12-31 21:40:55 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2023-12-31 21:40:55 -0700
commita17ff9e9db5ecf20542a69654ade63d9f3aa7220 (patch)
tree76693d1dfbab838d7787c61a51978e5ea5758fcb
parent8f681540e079a70632bbc11deb3f122c5ba348cd (diff)
file_blockbuf.go: Ensure the cache is flushed before closing
-rw-r--r--lib/diskio/file_blockbuf.go6
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) {