mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-09 19:20:56 +08:00
fix: Fix the issue of interface image loss caused by clearing cache (#9149)
Refs: #9050
This commit is contained in:
parent
10039c6173
commit
795223e7fa
1 changed files with 26 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -338,7 +339,7 @@ func doSystemClean(taskItem *task.Task) func(t *task.Task) error {
|
|||
}
|
||||
|
||||
dropWithTask(path.Join(global.Dir.BaseDir, tmpUploadPath), taskItem, &size, &fileCount)
|
||||
dropWithTask(path.Join(global.Dir.BaseDir, uploadPath), taskItem, &size, &fileCount)
|
||||
dropWithExclude(path.Join(global.Dir.BaseDir, uploadPath), []string{"theme"}, taskItem, &size, &fileCount)
|
||||
dropWithTask(path.Join(global.Dir.BaseDir, downloadPath), taskItem, &size, &fileCount)
|
||||
|
||||
logFiles, _ := os.ReadDir(global.Dir.LogDir)
|
||||
|
|
@ -714,6 +715,30 @@ func dropVolumes() {
|
|||
}
|
||||
}
|
||||
|
||||
func dropWithExclude(pathToDelete string, excludeSubDirs []string, taskItem *task.Task, size *int64, count *int) {
|
||||
entries, err := os.ReadDir(pathToDelete)
|
||||
if err != nil {
|
||||
taskItem.LogFailed(fmt.Sprintf("read dir %s failed: %v", pathToDelete, err))
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
fullPath := filepath.Join(pathToDelete, name)
|
||||
excluded := false
|
||||
for _, ex := range excludeSubDirs {
|
||||
if name == ex {
|
||||
excluded = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if excluded {
|
||||
continue
|
||||
}
|
||||
dropWithTask(fullPath, taskItem, size, count)
|
||||
}
|
||||
}
|
||||
|
||||
func dropWithTask(itemPath string, taskItem *task.Task, size *int64, count *int) {
|
||||
itemSize := int64(0)
|
||||
itemCount := 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue