Skip to content

Commit

Permalink
Delete destination paths for compaction
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wardle committed Sep 15, 2023
1 parent 5d3afc8 commit ffaacbf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/com/eldrix/hermes/impl/lmdb.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]))))
Expand Down

0 comments on commit ffaacbf

Please sign in to comment.