edge-node cache.garbage命令执行时检查Key列表是否已加载完毕

This commit is contained in:
刘祥超
2023-09-17 11:43:46 +08:00
parent 062ca1cfcd
commit bac0060a74
2 changed files with 13 additions and 0 deletions

View File

@@ -379,6 +379,15 @@ func (this *FileList) GetDB(hash string) *FileListDB {
return this.dbList[fnv.HashString(hash)%CountFileDB]
}
func (this *FileList) HashMapIsLoaded() bool {
for _, db := range this.dbList {
if !db.HashMapIsLoaded() {
return false
}
}
return true
}
func (this *FileList) remove(hash string) (notFound bool, err error) {
var db = this.GetDB(hash)

View File

@@ -1534,6 +1534,10 @@ func (this *FileStorage) subDir(hash string) (dirPath string, dirIsFull bool) {
// ScanGarbageCaches 清理目录中“失联”的缓存文件
// “失联”为不在HashMap中的文件
func (this *FileStorage) ScanGarbageCaches(fileCallback func(path string) error) error {
if !this.list.(*FileList).HashMapIsLoaded() {
return errors.New("cache list is loading")
}
var mainDir = this.options.Dir
var allDirs = []string{mainDir}
var subDirs = this.subDirs // copy