diff --git a/lib/fs/fs.go b/lib/fs/fs.go index ba61caed4..6332b90eb 100644 --- a/lib/fs/fs.go +++ b/lib/fs/fs.go @@ -262,7 +262,7 @@ func MustRemoveTemporaryDirs(dir string) { continue } dirName := fi.Name() - if strings.Contains(dirName, ".must-remove.") { + if IsScheduledForRemoval(dirName) { fullPath := dir + "/" + dirName MustRemoveAll(fullPath) } @@ -467,3 +467,7 @@ func isHTTPURL(targetURL string) bool { return err == nil && (parsed.Scheme == "http" || parsed.Scheme == "https") && parsed.Host != "" } + +func IsScheduledForRemoval(name string) bool { + return strings.Contains(name, ".must-remove.") +} diff --git a/lib/mergeset/table.go b/lib/mergeset/table.go index 0a25506d3..7c7d200a1 100644 --- a/lib/mergeset/table.go +++ b/lib/mergeset/table.go @@ -1835,5 +1835,5 @@ func removeParts(pws []*partWrapper, partsToRemove map[*partWrapper]bool) ([]*pa func isSpecialDir(name string) bool { // Snapshots and cache dirs aren't used anymore. // Keep them here for backwards compatibility. - return name == "tmp" || name == "txn" || name == "snapshots" || name == "cache" + return name == "tmp" || name == "txn" || name == "snapshots" || name == "cache" || fs.IsScheduledForRemoval(name) } diff --git a/lib/storage/partition.go b/lib/storage/partition.go index 01c3a7d7d..0b71e8bdb 100644 --- a/lib/storage/partition.go +++ b/lib/storage/partition.go @@ -2022,7 +2022,7 @@ func (pt *partition) createSnapshot(srcDir, dstDir string) error { // Skip non-directories. continue } - if fn == "tmp" || fn == "txn" { + if fn == "tmp" || fn == "txn" || fs.IsScheduledForRemoval(fn) { // Skip special dirs. continue }