From ffaacbf21f5d630cd0c30b6e26e201191890c074 Mon Sep 17 00:00:00 2001 From: Mark Wardle Date: Fri, 15 Sep 2023 17:49:28 +0100 Subject: [PATCH] Delete destination paths for compaction If the compacting process is interrupted, the intermediary copies of the data files can be left accidentally, thwarting any further attempt at compaction. This fixes #58 by deleting any leftover files before attempting compaction. --- src/com/eldrix/hermes/impl/lmdb.clj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/com/eldrix/hermes/impl/lmdb.clj b/src/com/eldrix/hermes/impl/lmdb.clj index 62307a86..170044c8 100644 --- a/src/com/eldrix/hermes/impl/lmdb.clj +++ b/src/com/eldrix/hermes/impl/lmdb.clj @@ -128,7 +128,9 @@ core' (.resolve path "core2.db") refsets (.resolve path "refsets.db") refsets' (.resolve path "refsets2.db")] + (Files/deleteIfExists core') (.copy ^Env (.-coreEnv store) (.toFile core') (into-array ^CopyFlags [CopyFlags/MDB_CP_COMPACT])) + (Files/deleteIfExists refsets') (.copy ^Env (.-refsetsEnv store) (.toFile refsets') (into-array ^CopyFlags [CopyFlags/MDB_CP_COMPACT])) (Files/move core' core (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING StandardCopyOption/ATOMIC_MOVE])) (Files/move refsets' refsets (into-array CopyOption [StandardCopyOption/REPLACE_EXISTING StandardCopyOption/ATOMIC_MOVE]))))