@@ -20,6 +20,7 @@ import (
20
20
const (
21
21
DefaultSnapshotInterval = 1000
22
22
LockFileName = "LOCK"
23
+ TmpSuffix = "-tmp"
23
24
)
24
25
25
26
var errReadOnly = errors .New ("db is read-only" )
@@ -259,7 +260,7 @@ func removeTmpDirs(rootDir string) error {
259
260
}
260
261
261
262
for _ , entry := range entries {
262
- if ! entry .IsDir () || ! strings .HasSuffix (entry .Name (), "-tmp" ) {
263
+ if ! entry .IsDir () || ! strings .HasSuffix (entry .Name (), TmpSuffix ) {
263
264
continue
264
265
}
265
266
@@ -628,7 +629,7 @@ func (db *DB) RewriteSnapshot() error {
628
629
}
629
630
630
631
snapshotDir := snapshotName (db .lastCommitInfo .Version )
631
- tmpDir := snapshotDir + "-tmp"
632
+ tmpDir := snapshotDir + TmpSuffix
632
633
path := filepath .Join (db .dir , tmpDir )
633
634
if err := db .MultiTree .WriteSnapshot (path ); err != nil {
634
635
return errors .Join (err , os .RemoveAll (path ))
@@ -835,7 +836,7 @@ func currentPath(root string) string {
835
836
}
836
837
837
838
func currentTmpPath (root string ) string {
838
- return filepath . Join (root , "current-tmp" )
839
+ return currentPath (root ) + TmpSuffix
839
840
}
840
841
841
842
func currentVersion (root string ) (int64 , error ) {
@@ -981,7 +982,7 @@ func traverseSnapshots(dir string, ascending bool, callback func(int64) (bool, e
981
982
982
983
// atomicRemoveDir is equavalent to `mv snapshot snapshot-tmp && rm -r snapshot-tmp`
983
984
func atomicRemoveDir (path string ) error {
984
- tmpPath := path + "-tmp"
985
+ tmpPath := path + TmpSuffix
985
986
if err := os .Rename (path , tmpPath ); err != nil {
986
987
return err
987
988
}
0 commit comments