From f9d7cb385cadda93800b9cf848d7da0c1516c254 Mon Sep 17 00:00:00 2001 From: Calvin Kim Date: Mon, 1 Jul 2024 20:15:18 +0900 Subject: [PATCH] ffldb: close block files On methods readBlock and readBlockRegion, the opened files were never closed which resulted in errors when attempting to delete these files on pruning on windows. Properly closing the files avoids this error. --- database/ffldb/blockio.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/database/ffldb/blockio.go b/database/ffldb/blockio.go index 2b415a17b0..1a9592691b 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -524,6 +524,7 @@ func (s *blockStore) readBlock(hash *chainhash.Hash, loc blockLocation) ([]byte, serializedData := make([]byte, loc.blockLen) n, err := blockFile.file.ReadAt(serializedData, int64(loc.fileOffset)) blockFile.RUnlock() + blockFile.file.Close() if err != nil { str := fmt.Sprintf("failed to read block %s from file %d, "+ "offset %d: %v", hash, loc.blockFileNum, loc.fileOffset, @@ -584,6 +585,7 @@ func (s *blockStore) readBlockRegion(loc blockLocation, offset, numBytes uint32) serializedData := make([]byte, numBytes) _, err = blockFile.file.ReadAt(serializedData, int64(readOffset)) blockFile.RUnlock() + blockFile.file.Close() if err != nil { str := fmt.Sprintf("failed to read region from block file %d, "+ "offset %d, len %d: %v", loc.blockFileNum, readOffset,