Skip to content

Commit 3d82eb7

Browse files
committed
fix: Fix the issue of abnormal cache cleanup display
1 parent 6ab1418 commit 3d82eb7

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

agent/app/service/device_clean.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/1Panel-dev/1Panel/agent/global"
2020
"github.com/1Panel-dev/1Panel/agent/i18n"
2121
"github.com/1Panel-dev/1Panel/agent/utils/common"
22-
"github.com/1Panel-dev/1Panel/agent/utils/controller"
2322
"github.com/1Panel-dev/1Panel/agent/utils/docker"
2423
fileUtils "github.com/1Panel-dev/1Panel/agent/utils/files"
2524
"github.com/docker/docker/api/types"
@@ -30,7 +29,6 @@ import (
3029

3130
const (
3231
rollbackPath = "1panel/tmp"
33-
cachePath = "1panel/cache"
3432
upgradePath = "1panel/tmp/upgrade"
3533
uploadPath = "1panel/uploads"
3634
downloadPath = "1panel/download"
@@ -56,16 +54,6 @@ func (u *DeviceService) Scan() dto.CleanData {
5654
})
5755
treeData = append(treeData, loadUpgradeTree(fileOp))
5856
treeData = append(treeData, loadAgentPackage(fileOp))
59-
cachePath := path.Join(global.Dir.BaseDir, cachePath)
60-
cacheSize, _ := fileOp.GetDirSize(cachePath)
61-
treeData = append(treeData, dto.CleanTree{
62-
ID: uuid.NewString(),
63-
Label: "cache",
64-
Size: uint64(cacheSize),
65-
IsCheck: false,
66-
IsRecommend: false,
67-
Type: "cache",
68-
})
6957

7058
SystemClean.BackupClean = loadBackupTree(fileOp)
7159

@@ -102,7 +90,6 @@ func (u *DeviceService) Scan() dto.CleanData {
10290

10391
func (u *DeviceService) Clean(req []dto.Clean) {
10492
size := uint64(0)
105-
restart := false
10693
for _, item := range req {
10794
size += item.Size
10895
switch item.TreeType {
@@ -131,10 +118,6 @@ func (u *DeviceService) Clean(req []dto.Clean) {
131118
case "rollback_website":
132119
dropFileOrDir(path.Join(global.Dir.BaseDir, rollbackPath, "website", item.Name))
133120

134-
case "cache":
135-
dropFileOrDir(path.Join(global.Dir.BaseDir, cachePath, item.Name))
136-
restart = true
137-
138121
case "upload":
139122
dropFileOrDir(path.Join(global.Dir.BaseDir, uploadPath, item.Name))
140123
case "upload_app":
@@ -202,10 +185,6 @@ func (u *DeviceService) Clean(req []dto.Clean) {
202185
_ = settingRepo.Update("LastCleanTime", time.Now().Format(constant.DateTimeLayout))
203186
_ = settingRepo.Update("LastCleanSize", fmt.Sprintf("%v", size))
204187
_ = settingRepo.Update("LastCleanData", fmt.Sprintf("%v", len(req)))
205-
206-
if restart {
207-
go controller.RestartPanel(false, true, false)
208-
}
209188
}
210189

211190
func doSystemClean(taskItem *task.Task) func(t *task.Task) error {
@@ -327,6 +306,7 @@ func loadAgentPackage(fileOp fileUtils.FileOp) dto.CleanTree {
327306
itemTree.Size += uint64(itemSize)
328307
itemTree.Children = append(itemTree.Children, dto.CleanTree{
329308
ID: uuid.NewString(),
309+
Label: file.Name(),
330310
Name: file.Name(),
331311
Size: uint64(itemSize),
332312
IsCheck: true,
@@ -342,6 +322,7 @@ func loadAgentPackage(fileOp fileUtils.FileOp) dto.CleanTree {
342322
itemTree.Children = append(itemTree.Children, dto.CleanTree{
343323
ID: uuid.NewString(),
344324
Label: file.Name(),
325+
Name: file.Name(),
345326
Size: uint64(itemSize.Size()),
346327
IsCheck: true,
347328
IsRecommend: true,
@@ -598,6 +579,9 @@ func loadBackupIsCheck(treeData *dto.CleanTree) {
598579
treeData.Children[i].IsRecommend = true
599580
continue
600581
}
582+
if treeData.Label != "unknown_database" && treeData.Label != "unknown_app" {
583+
continue
584+
}
601585
for j := 0; j < len(treeData.Children[i].Children); j++ {
602586
if len(treeData.Children[i].Children[j].Children) == 0 {
603587
treeData.Children[i].Children[j].IsCheck = true

0 commit comments

Comments
 (0)