This commit is contained in:
Liang Ding 2023-01-09 20:28:11 +08:00
parent 68b0f4e8b3
commit 1085926f8d
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 18 additions and 1 deletions

View file

@ -1258,7 +1258,7 @@ func autoFixIndex() {
redundantPaths := treenode.GetRedundantPaths(box.ID, paths)
for _, p := range redundantPaths {
treenode.RemoveBlockTreesByPathPrefix(p)
treenode.RemoveBlockTreesByPath(p)
}
missingPaths := treenode.GetNotExistPaths(box.ID, paths)

View file

@ -224,6 +224,23 @@ func RemoveBlockTreesByRootID(rootID string) {
blockTreesChanged = true
}
func RemoveBlockTreesByPath(path string) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()
var ids []string
for _, b := range blockTrees {
if b.Path == path {
ids = append(ids, b.ID)
}
}
ids = gulu.Str.RemoveDuplicatedElem(ids)
for _, id := range ids {
delete(blockTrees, id)
}
blockTreesChanged = true
}
func RemoveBlockTreesByPathPrefix(pathPrefix string) {
blockTreesLock.Lock()
defer blockTreesLock.Unlock()