lib/{fs,mergeset,storage}: skip .must-remove. dirs when creating snapshot (#3858) (#3867)

This commit is contained in:
Zakhar Bessarab 2023-02-25 00:38:42 +04:00 committed by GitHub
parent a2340e6c95
commit d8eaa511b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View file

@ -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.")
}

View file

@ -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)
}

View file

@ -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
}