@@ -20,6 +20,7 @@ const (
20
20
DefaultSnapshotInterval = 1000
21
21
LockFileName = "LOCK"
22
22
DefaultSnapshotWriterLimit = 4
23
+ TmpSuffix = "-tmp"
23
24
)
24
25
25
26
var errReadOnly = errors .New ("db is read-only" )
@@ -265,7 +266,7 @@ func removeTmpDirs(rootDir string) error {
265
266
}
266
267
267
268
for _ , entry := range entries {
268
- if ! entry .IsDir () || ! strings .HasSuffix (entry .Name (), "-tmp" ) {
269
+ if ! entry .IsDir () || ! strings .HasSuffix (entry .Name (), TmpSuffix ) {
269
270
continue
270
271
}
271
272
@@ -636,7 +637,7 @@ func (db *DB) RewriteSnapshot() error {
636
637
}
637
638
638
639
snapshotDir := snapshotName (db .lastCommitInfo .Version )
639
- tmpDir := snapshotDir + "-tmp"
640
+ tmpDir := snapshotDir + TmpSuffix
640
641
path := filepath .Join (db .dir , tmpDir )
641
642
if err := db .MultiTree .WriteSnapshot (path , db .snapshotWriterPool ); err != nil {
642
643
return errors .Join (err , os .RemoveAll (path ))
@@ -978,7 +979,7 @@ func traverseSnapshots(dir string, ascending bool, callback func(int64) (bool, e
978
979
979
980
// atomicRemoveDir is equavalent to `mv snapshot snapshot-tmp && rm -r snapshot-tmp`
980
981
func atomicRemoveDir (path string ) error {
981
- tmpPath := path + "-tmp"
982
+ tmpPath := path + TmpSuffix
982
983
if err := os .Rename (path , tmpPath ); err != nil {
983
984
return err
984
985
}
0 commit comments