diff --git a/internal/caches/storage_file.go b/internal/caches/storage_file.go index 9591139..ba5b1df 100644 --- a/internal/caches/storage_file.go +++ b/internal/caches/storage_file.go @@ -579,16 +579,18 @@ func (this *FileStorage) initList() error { return err } - dir := this.dir() + // 使用异步防止阻塞主线程 + go func() { + dir := this.dir() - // 清除tmp - files, err := filepath.Glob(dir + "/*/*/*.cache.tmp") - if err != nil { - return err - } - for _, path := range files { - _ = os.Remove(path) - } + // 清除tmp + files, err := filepath.Glob(dir + "/*/*/*.cache.tmp") + if err == nil && len(files) > 0 { + for _, path := range files { + _ = os.Remove(path) + } + } + }() // 启动定时清理任务 this.ticker = utils.NewTicker(30 * time.Second)