From 8825de369c42c0dded782745cd7232aca27ff2ae Mon Sep 17 00:00:00 2001 From: Adam Risberg Date: Thu, 19 Aug 2021 17:30:02 +0200 Subject: [PATCH] Fix recovery issue on windows. --- src/main/java/com/oath/halodb/HaloDBFile.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/oath/halodb/HaloDBFile.java b/src/main/java/com/oath/halodb/HaloDBFile.java index 89ceeb5..b2be420 100644 --- a/src/main/java/com/oath/halodb/HaloDBFile.java +++ b/src/main/java/com/oath/halodb/HaloDBFile.java @@ -176,11 +176,13 @@ HaloDBFile repairFile(DBDirectory dbDirectory) throws IOException { logger.info("Recovered {} records from file {} with size {}. Size after repair {}.", count, getName(), getSize(), repairFile.getSize()); repairFile.flushToDisk(); repairFile.indexFile.flushToDisk(); + indexFile.close(); + repairFile.indexFile.close(); Files.move(repairFile.indexFile.getPath(), indexFile.getPath(), REPLACE_EXISTING, ATOMIC_MOVE); - Files.move(repairFile.getPath(), getPath(), REPLACE_EXISTING, ATOMIC_MOVE); - dbDirectory.syncMetaData(); repairFile.close(); close(); + Files.move(repairFile.getPath(), getPath(), REPLACE_EXISTING, ATOMIC_MOVE); + dbDirectory.syncMetaData(); return openForReading(dbDirectory, getPath().toFile(), fileType, options); }