mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-25 06:56:32 +08:00
fix: Optimize toolbox cache cleaning functionality (#9902)
Refs #6550 #6582
This commit is contained in:
parent
fe39545cf6
commit
c12bab477c
17 changed files with 68 additions and 315 deletions
|
|
@ -314,30 +314,6 @@ func (b *BaseApi) UpdateCronjobStatus(c *gin.Context) {
|
|||
helper.Success(c)
|
||||
}
|
||||
|
||||
// @Tags Cronjob
|
||||
// @Summary Download cronjob records
|
||||
// @Accept json
|
||||
// @Param request body dto.CronjobDownload true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Security Timestamp
|
||||
// @Router /cronjobs/download [post]
|
||||
// @x-panel-log {"bodyKeys":["recordID"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"recordID","isList":false,"db":"job_records","output_column":"file","output_value":"file"}],"formatZH":"下载计划任务记录 [file]","formatEN":"download the cronjob record [file]"}
|
||||
func (b *BaseApi) TargetDownload(c *gin.Context) {
|
||||
var req dto.CronjobDownload
|
||||
if err := helper.CheckBindAndValidate(&req, c); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
filePath, err := cronjobService.Download(req)
|
||||
if err != nil {
|
||||
helper.InternalServer(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.File(filePath)
|
||||
}
|
||||
|
||||
// @Tags Cronjob
|
||||
// @Summary Handle cronjob once
|
||||
// @Accept json
|
||||
|
|
|
|||
|
|
@ -65,11 +65,6 @@ type CronjobUpdateStatus struct {
|
|||
Status string `json:"status" validate:"required"`
|
||||
}
|
||||
|
||||
type CronjobDownload struct {
|
||||
RecordID uint `json:"recordID" validate:"required"`
|
||||
BackupAccountID uint `json:"backupAccountID" validate:"required"`
|
||||
}
|
||||
|
||||
type CronjobClean struct {
|
||||
IsDelete bool `json:"isDelete"`
|
||||
CleanData bool `json:"cleanData"`
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ type ICronjobService interface {
|
|||
UpdateStatus(id uint, status string) error
|
||||
UpdateGroup(req dto.ChangeGroup) error
|
||||
Delete(req dto.CronjobBatchDelete) error
|
||||
Download(down dto.CronjobDownload) (string, error)
|
||||
StartJob(cronjob *model.Cronjob, isUpdate bool) (string, error)
|
||||
CleanRecord(req dto.CronjobClean) error
|
||||
|
||||
|
|
@ -535,32 +534,6 @@ func (u *CronjobService) CleanRecord(req dto.CronjobClean) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (u *CronjobService) Download(req dto.CronjobDownload) (string, error) {
|
||||
record, _ := cronjobRepo.GetRecord(repo.WithByID(req.RecordID))
|
||||
if record.ID == 0 {
|
||||
return "", buserr.New("ErrRecordNotFound")
|
||||
}
|
||||
account, client, err := NewBackupClientWithID(req.BackupAccountID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if account.Type == "LOCAL" || record.FromLocal {
|
||||
if _, err := os.Stat(record.File); err != nil && os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
return record.File, nil
|
||||
}
|
||||
tempPath := fmt.Sprintf("%s/download/%s", global.Dir.DataDir, record.File)
|
||||
if _, err := os.Stat(tempPath); err != nil && os.IsNotExist(err) {
|
||||
_ = os.MkdirAll(path.Dir(tempPath), os.ModePerm)
|
||||
isOK, err := client.Download(record.File, tempPath)
|
||||
if !isOK || err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
return tempPath, nil
|
||||
}
|
||||
|
||||
func (u *CronjobService) HandleOnce(id uint) error {
|
||||
cronjob, _ := cronjobRepo.Get(repo.WithByID(id))
|
||||
if cronjob.ID == 0 {
|
||||
|
|
|
|||
|
|
@ -78,19 +78,19 @@ func (u *DeviceService) Scan() dto.CleanData {
|
|||
}
|
||||
treeData = append(treeData, upgradeTree)
|
||||
|
||||
snapTree := loadSnapshotTree(fileOp)
|
||||
snapSize := uint64(0)
|
||||
for _, snap := range snapTree {
|
||||
snapSize += snap.Size
|
||||
tmpBackupTree := loadTmpBackupTree(fileOp)
|
||||
tmpBackupSize := uint64(0)
|
||||
for _, tmp := range tmpBackupTree {
|
||||
tmpBackupSize += tmp.Size
|
||||
}
|
||||
treeData = append(treeData, dto.CleanTree{
|
||||
ID: uuid.NewString(),
|
||||
Label: "snapshot",
|
||||
Size: snapSize,
|
||||
IsCheck: snapSize > 0,
|
||||
Label: "backup",
|
||||
Size: tmpBackupSize,
|
||||
IsCheck: tmpBackupSize > 0,
|
||||
IsRecommend: true,
|
||||
Type: "snapshot",
|
||||
Children: snapTree,
|
||||
Type: "backup",
|
||||
Children: tmpBackupTree,
|
||||
})
|
||||
|
||||
rollBackTree := loadRollBackTree(fileOp)
|
||||
|
|
@ -118,21 +118,6 @@ func (u *DeviceService) Scan() dto.CleanData {
|
|||
IsRecommend: false,
|
||||
Type: "cache",
|
||||
})
|
||||
|
||||
unusedTree := loadUnusedFile(fileOp)
|
||||
unusedSize := uint64(0)
|
||||
for _, unused := range unusedTree {
|
||||
unusedSize += unused.Size
|
||||
}
|
||||
treeData = append(treeData, dto.CleanTree{
|
||||
ID: uuid.NewString(),
|
||||
Label: "unused",
|
||||
Size: unusedSize,
|
||||
IsCheck: unusedSize > 0,
|
||||
IsRecommend: true,
|
||||
Type: "unused",
|
||||
Children: unusedTree,
|
||||
})
|
||||
SystemClean.SystemClean = treeData
|
||||
|
||||
uploadTreeData := loadUploadTree(fileOp)
|
||||
|
|
@ -162,13 +147,13 @@ func (u *DeviceService) Clean(req []dto.Clean) {
|
|||
case "upgrade":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, upgradePath, item.Name))
|
||||
|
||||
case "snapshot":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, snapshotTmpPath, item.Name))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "system", item.Name))
|
||||
case "snapshot_tmp":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, snapshotTmpPath, item.Name))
|
||||
case "snapshot_local":
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "system", item.Name))
|
||||
case "backup":
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/app"))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/database"))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/website"))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/directory"))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/log"))
|
||||
dropFileOrDir(path.Join(global.Dir.LocalBackupDir, "tmp/system"))
|
||||
|
||||
case "rollback":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, rollbackPath, "app"))
|
||||
|
|
@ -185,40 +170,6 @@ func (u *DeviceService) Clean(req []dto.Clean) {
|
|||
dropFileOrDir(path.Join(global.Dir.BaseDir, cachePath, item.Name))
|
||||
restart = true
|
||||
|
||||
case "unused":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldOriginalPath))
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldAppBackupPath))
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldDownloadPath))
|
||||
files, _ := os.ReadDir(path.Join(global.Dir.BaseDir, oldUpgradePath))
|
||||
if len(files) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, file := range files {
|
||||
if strings.HasPrefix(file.Name(), "upgrade_") {
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldUpgradePath, file.Name()))
|
||||
}
|
||||
}
|
||||
case "old_original":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldOriginalPath, item.Name))
|
||||
case "old_apps_bak":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldAppBackupPath, item.Name))
|
||||
case "old_download":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldDownloadPath, item.Name))
|
||||
case "old_upgrade":
|
||||
if len(item.Name) == 0 {
|
||||
files, _ := os.ReadDir(path.Join(global.Dir.BaseDir, oldUpgradePath))
|
||||
if len(files) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, file := range files {
|
||||
if strings.HasPrefix(file.Name(), "upgrade_") {
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldUpgradePath, file.Name()))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, oldUpgradePath, item.Name))
|
||||
}
|
||||
|
||||
case "upload":
|
||||
dropFileOrDir(path.Join(global.Dir.BaseDir, uploadPath, item.Name))
|
||||
if len(item.Name) == 0 {
|
||||
|
|
@ -367,106 +318,32 @@ func doSystemClean(taskItem *task.Task) func(t *task.Task) error {
|
|||
}
|
||||
}
|
||||
|
||||
func loadSnapshotTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
func loadTmpBackupTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
var treeData []dto.CleanTree
|
||||
path1 := path.Join(global.Dir.BaseDir, snapshotTmpPath)
|
||||
list1 := loadTreeWithAllFile(true, path1, "snapshot_tmp", path1, fileOp)
|
||||
if len(list1) != 0 {
|
||||
size, _ := fileOp.GetDirSize(path1)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "snapshot_tmp", Size: uint64(size), Children: list1, Type: "snapshot_tmp", IsRecommend: true})
|
||||
}
|
||||
|
||||
path2 := path.Join(global.Dir.LocalBackupDir, "system")
|
||||
list2 := loadTreeWithAllFile(true, path2, "snapshot_local", path2, fileOp)
|
||||
if len(list2) != 0 {
|
||||
size, _ := fileOp.GetDirSize(path2)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "snapshot_local", Size: uint64(size), Children: list2, Type: "snapshot_local", IsRecommend: true})
|
||||
}
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/app"), "tmp_backup_app", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/website"), "tmp_backup_website", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/database"), "tmp_backup_database", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/system"), "tmp_backup_snapshot", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/directory"), "tmp_backup_directory", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.LocalBackupDir, "tmp/log"), "tmp_backup_log", fileOp)
|
||||
return treeData
|
||||
}
|
||||
|
||||
func loadRollBackTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
var treeData []dto.CleanTree
|
||||
path1 := path.Join(global.Dir.BaseDir, rollbackPath, "app")
|
||||
list1 := loadTreeWithAllFile(true, path1, "rollback_app", path1, fileOp)
|
||||
size1, _ := fileOp.GetDirSize(path1)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "rollback_app", Size: uint64(size1), Children: list1, Type: "rollback_app", IsRecommend: true})
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, rollbackPath, "app"), "rollback_app", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, rollbackPath, "website"), "rollback_website", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, rollbackPath, "database"), "rollback_database", fileOp)
|
||||
|
||||
path2 := path.Join(global.Dir.BaseDir, rollbackPath, "website")
|
||||
list2 := loadTreeWithAllFile(true, path2, "rollback_website", path2, fileOp)
|
||||
size2, _ := fileOp.GetDirSize(path2)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "rollback_website", Size: uint64(size2), Children: list2, Type: "rollback_website", IsRecommend: true})
|
||||
|
||||
path3 := path.Join(global.Dir.BaseDir, rollbackPath, "database")
|
||||
list3 := loadTreeWithAllFile(true, path3, "rollback_database", path3, fileOp)
|
||||
size3, _ := fileOp.GetDirSize(path3)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "rollback_database", Size: uint64(size3), Children: list3, Type: "rollback_database", IsRecommend: true})
|
||||
|
||||
return treeData
|
||||
}
|
||||
|
||||
func loadUnusedFile(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
var treeData []dto.CleanTree
|
||||
path1 := path.Join(global.Dir.BaseDir, oldOriginalPath)
|
||||
list1 := loadTreeWithAllFile(true, path1, "old_original", path1, fileOp)
|
||||
if len(list1) != 0 {
|
||||
size, _ := fileOp.GetDirSize(path1)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "old_original", Size: uint64(size), Children: list1, Type: "old_original"})
|
||||
}
|
||||
|
||||
path2 := path.Join(global.Dir.BaseDir, oldAppBackupPath)
|
||||
list2 := loadTreeWithAllFile(true, path2, "old_apps_bak", path2, fileOp)
|
||||
if len(list2) != 0 {
|
||||
size, _ := fileOp.GetDirSize(path2)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "old_apps_bak", Size: uint64(size), Children: list2, Type: "old_apps_bak"})
|
||||
}
|
||||
|
||||
path3 := path.Join(global.Dir.BaseDir, oldDownloadPath)
|
||||
list3 := loadTreeWithAllFile(true, path3, "old_download", path3, fileOp)
|
||||
if len(list3) != 0 {
|
||||
size, _ := fileOp.GetDirSize(path3)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "old_download", Size: uint64(size), Children: list3, Type: "old_download"})
|
||||
}
|
||||
|
||||
path4 := path.Join(global.Dir.BaseDir, oldUpgradePath)
|
||||
list4 := loadTreeWithDir(true, "old_upgrade", path4, fileOp)
|
||||
itemSize := uint64(0)
|
||||
for _, item := range list4 {
|
||||
itemSize += item.Size
|
||||
}
|
||||
if len(list4) != 0 {
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "old_upgrade", Size: itemSize, Children: list4, Type: "old_upgrade"})
|
||||
}
|
||||
return treeData
|
||||
}
|
||||
|
||||
func loadUploadTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
var treeData []dto.CleanTree
|
||||
|
||||
path0 := path.Join(global.Dir.BaseDir, tmpUploadPath)
|
||||
list0 := loadTreeWithAllFile(true, path0, "upload_tmp", path0, fileOp)
|
||||
size0, _ := fileOp.GetDirSize(path0)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_tmp", Size: uint64(size0), Children: list0, Type: "upload_tmp", IsRecommend: true})
|
||||
|
||||
path1 := path.Join(global.Dir.BaseDir, uploadPath, "app")
|
||||
list1 := loadTreeWithAllFile(true, path1, "upload_app", path1, fileOp)
|
||||
size1, _ := fileOp.GetDirSize(path1)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_app", Size: uint64(size1), Children: list1, Type: "upload_app", IsRecommend: true})
|
||||
|
||||
path2 := path.Join(global.Dir.BaseDir, uploadPath, "website")
|
||||
list2 := loadTreeWithAllFile(true, path2, "upload_website", path2, fileOp)
|
||||
size2, _ := fileOp.GetDirSize(path2)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_website", Size: uint64(size2), Children: list2, Type: "upload_website", IsRecommend: true})
|
||||
|
||||
path3 := path.Join(global.Dir.BaseDir, uploadPath, "database")
|
||||
list3 := loadTreeWithAllFile(true, path3, "upload_database", path3, fileOp)
|
||||
size3, _ := fileOp.GetDirSize(path3)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_database", Size: uint64(size3), Children: list3, Type: "upload_database", IsRecommend: true})
|
||||
|
||||
path4 := path.Join(global.Dir.BaseDir, uploadPath, "directory")
|
||||
list4 := loadTreeWithAllFile(true, path4, "upload_directory", path4, fileOp)
|
||||
size4, _ := fileOp.GetDirSize(path4)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "upload_directory", Size: uint64(size4), Children: list4, Type: "upload_directory", IsRecommend: true})
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, tmpUploadPath), "upload_tmp", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, uploadPath, "app"), "upload_app", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, uploadPath, "website"), "upload_website", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, uploadPath, "database"), "upload_database", fileOp)
|
||||
|
||||
path5 := path.Join(global.Dir.BaseDir, uploadPath)
|
||||
uploadTreeData := loadTreeWithAllFile(true, path5, "upload", path5, fileOp)
|
||||
|
|
@ -477,25 +354,9 @@ func loadUploadTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
|||
|
||||
func loadDownloadTree(fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
var treeData []dto.CleanTree
|
||||
path1 := path.Join(global.Dir.BaseDir, downloadPath, "app")
|
||||
list1 := loadTreeWithAllFile(true, path1, "download_app", path1, fileOp)
|
||||
size1, _ := fileOp.GetDirSize(path1)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_app", Size: uint64(size1), Children: list1, Type: "download_app", IsRecommend: true})
|
||||
|
||||
path2 := path.Join(global.Dir.BaseDir, downloadPath, "website")
|
||||
list2 := loadTreeWithAllFile(true, path2, "download_website", path2, fileOp)
|
||||
size2, _ := fileOp.GetDirSize(path2)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_website", Size: uint64(size2), Children: list2, Type: "download_website", IsRecommend: true})
|
||||
|
||||
path3 := path.Join(global.Dir.BaseDir, downloadPath, "database")
|
||||
list3 := loadTreeWithAllFile(true, path3, "download_database", path3, fileOp)
|
||||
size3, _ := fileOp.GetDirSize(path3)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_database", Size: uint64(size3), Children: list3, Type: "download_database", IsRecommend: true})
|
||||
|
||||
path4 := path.Join(global.Dir.BaseDir, downloadPath, "directory")
|
||||
list4 := loadTreeWithAllFile(true, path4, "download_directory", path4, fileOp)
|
||||
size4, _ := fileOp.GetDirSize(path4)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "download_directory", Size: uint64(size4), Children: list4, Type: "download_directory", IsRecommend: true})
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, downloadPath, "app"), "download_app", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, downloadPath, "website"), "download_website", fileOp)
|
||||
treeData = loadTreeWithCheck(treeData, path.Join(global.Dir.BaseDir, downloadPath, "database"), "download_database", fileOp)
|
||||
|
||||
path5 := path.Join(global.Dir.BaseDir, downloadPath)
|
||||
uploadTreeData := loadTreeWithAllFile(true, path5, "download", path5, fileOp)
|
||||
|
|
@ -558,7 +419,7 @@ func loadContainerTree() []dto.CleanTree {
|
|||
volumeSize += uint64(file.UsageData.Size)
|
||||
}
|
||||
}
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "container_volumes", Size: volumeSize, Children: nil, Type: "volumes", IsRecommend: true})
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "container_volumes", Size: volumeSize, IsCheck: volumeSize > 0, Children: nil, Type: "volumes", IsRecommend: true})
|
||||
|
||||
var buildCacheTotalSize int64
|
||||
for _, cache := range diskUsage.BuildCache {
|
||||
|
|
@ -566,7 +427,17 @@ func loadContainerTree() []dto.CleanTree {
|
|||
buildCacheTotalSize += cache.Size
|
||||
}
|
||||
}
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "build_cache", Size: uint64(buildCacheTotalSize), Type: "build_cache", IsRecommend: true})
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: "build_cache", Size: uint64(buildCacheTotalSize), IsCheck: buildCacheTotalSize > 0, Type: "build_cache", IsRecommend: true})
|
||||
return treeData
|
||||
}
|
||||
|
||||
func loadTreeWithCheck(treeData []dto.CleanTree, pathItem, treeType string, fileOp fileUtils.FileOp) []dto.CleanTree {
|
||||
size, _ := fileOp.GetDirSize(pathItem)
|
||||
if size == 0 {
|
||||
return treeData
|
||||
}
|
||||
list := loadTreeWithAllFile(true, pathItem, treeType, pathItem, fileOp)
|
||||
treeData = append(treeData, dto.CleanTree{ID: uuid.NewString(), Label: treeType, Size: uint64(size), IsCheck: size > 0, Children: list, Type: treeType, IsRecommend: true})
|
||||
return treeData
|
||||
}
|
||||
|
||||
|
|
@ -577,9 +448,6 @@ func loadTreeWithDir(isCheck bool, treeType, pathItem string, fileOp fileUtils.F
|
|||
return lists
|
||||
}
|
||||
for _, file := range files {
|
||||
if treeType == "old_upgrade" {
|
||||
continue
|
||||
}
|
||||
if file.Name() == "ssl" {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ func (s *CronjobRouter) InitRouter(Router *gin.RouterGroup) {
|
|||
cmdRouter.POST("/group/update", baseApi.UpdateCronjobGroup)
|
||||
cmdRouter.POST("/status", baseApi.UpdateCronjobStatus)
|
||||
cmdRouter.POST("/handle", baseApi.HandleOnce)
|
||||
cmdRouter.POST("/download", baseApi.TargetDownload)
|
||||
cmdRouter.POST("/search", baseApi.SearchCronjob)
|
||||
cmdRouter.POST("/search/records", baseApi.SearchJobRecords)
|
||||
cmdRouter.POST("/records/log", baseApi.LoadRecordLog)
|
||||
|
|
|
|||
|
|
@ -54,24 +54,10 @@ export const cleanRecords = (id: number, cleanData: boolean, cleanRemoteData: bo
|
|||
return http.post(`cronjobs/records/clean`, { cronjobID: id, cleanData: cleanData, cleanRemoteData });
|
||||
};
|
||||
|
||||
export const getRecordDetail = (params: string) => {
|
||||
return http.post<string>(`cronjobs/search/detail`, { path: params });
|
||||
};
|
||||
|
||||
export const updateStatus = (params: Cronjob.UpdateStatus) => {
|
||||
return http.post(`cronjobs/status`, params);
|
||||
};
|
||||
|
||||
export const downloadRecordCheck = (params: Cronjob.Download) => {
|
||||
return http.post<string>(`cronjobs/download`, params, TimeoutEnum.T_40S);
|
||||
};
|
||||
export const downloadRecord = (params: Cronjob.Download) => {
|
||||
return http.download<BlobPart>(`cronjobs/download`, params, {
|
||||
responseType: 'blob',
|
||||
timeout: TimeoutEnum.T_40S,
|
||||
});
|
||||
};
|
||||
|
||||
export const handleOnce = (id: number) => {
|
||||
return http.post(`cronjobs/handle`, { id: id });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2023,18 +2023,13 @@ const message = {
|
|||
systemHelper:
|
||||
'Temporary files generated during snapshots, upgrades, and obsolete file contents during version iterations',
|
||||
panelOriginal: 'System snapshot recovery backup files',
|
||||
backup: 'Temporary backup directory',
|
||||
upgrade: 'System upgrade backup files',
|
||||
upgradeHelper: '(Recommend keeping the latest upgrade backup for system rollback)',
|
||||
cache: 'System cache files',
|
||||
cacheHelper: '(Proceed with caution, cleaning requires a service restart)',
|
||||
snapshot: 'System snapshot temporary files',
|
||||
snapshotTmp: 'System snapshot upload temporary files',
|
||||
snapshotLocal: 'System snapshot creation temporary files',
|
||||
rollback: 'Backup files before recover',
|
||||
unused: 'Unused system directories',
|
||||
oldUpgrade: 'Unused pre-upgrade backup directories',
|
||||
oldOriginal: 'Unused pre-snapshot recovery backup directories',
|
||||
oldAppsBak: 'Unused application backup directories',
|
||||
|
||||
upload: 'Temporary Upload Files',
|
||||
uploadHelper: 'Temporary files uploaded from the system backup list',
|
||||
|
|
|
|||
|
|
@ -1939,17 +1939,12 @@ const message = {
|
|||
systemHelper:
|
||||
'スナップショット中に生成された一時ファイル、アップグレード、およびバージョンの反復中にファイルのコンテンツが廃止されました',
|
||||
panelOriginal: 'システムスナップショットリカバリバックアップファイル',
|
||||
backup: '一時バックアップディレクトリ',
|
||||
upgrade: 'システムアップグレードバックアップファイル',
|
||||
upgradeHelper: '(システムロールバックのために最新のアップグレードバックアップを保持することをお勧めします)',
|
||||
cache: 'システムキャッシュファイル',
|
||||
cacheHelper: '(注意を払って進むには、クリーニングにはサービスの再起動が必要です)',
|
||||
snapshotTmp: 'システムスナップショット一時ファイルをアップロードします',
|
||||
snapshotLocal: 'システムスナップショット作成の一時ファイル',
|
||||
rollback: '回復する前にファイルをバックアップします',
|
||||
unused: '未使用のシステムディレクトリ',
|
||||
oldUpgrade: '未使用のプリアップグレードバックアップディレクトリ',
|
||||
oldOriginal: '未使用のスナップショットリカバリバックアップディレクトリ',
|
||||
oldAppsBak: '未使用のアプリケーションバックアップディレクトリ',
|
||||
|
||||
upload: '一時的なアップロードファイル',
|
||||
uploadHelper: 'システムバックアップリストからアップロードされた一時ファイル',
|
||||
|
|
|
|||
|
|
@ -1906,17 +1906,12 @@ const message = {
|
|||
system: '시스템 불필요 파일',
|
||||
systemHelper: '스냅샷, 업그레이드 중에 생성된 임시 파일과 버전 업데이트 중에 불필요해진 파일 내용',
|
||||
panelOriginal: '시스템 스냅샷 복구 백업 파일',
|
||||
backup: '임시 백업 디렉터리',
|
||||
upgrade: '시스템 업그레이드 백업 파일',
|
||||
upgradeHelper: '(시스템 롤백을 위해 최신 업그레이드 백업을 유지하는 것이 좋습니다)',
|
||||
cache: '시스템 캐시 파일',
|
||||
cacheHelper: '(주의하여 진행, 정리 후 서비스 재시작 필요)',
|
||||
snapshotTmp: '시스템 스냅샷 업로드 임시 파일',
|
||||
snapshotLocal: '시스템 스냅샷 생성 임시 파일',
|
||||
rollback: '복구 전 백업 파일',
|
||||
unused: '사용되지 않는 시스템 디렉터리',
|
||||
oldUpgrade: '사용되지 않는 구버전 업그레이드 백업 디렉터리',
|
||||
oldOriginal: '사용되지 않는 구버전 스냅샷 복구 백업 디렉터리',
|
||||
oldAppsBak: '사용되지 않는 애플리케이션 백업 디렉터리',
|
||||
|
||||
upload: '임시 업로드 파일',
|
||||
uploadHelper: '시스템 백업 리스트에서 업로드된 임시 파일',
|
||||
|
|
|
|||
|
|
@ -1997,17 +1997,12 @@ const message = {
|
|||
systemHelper:
|
||||
'Fail sementara yang dihasilkan semasa snapshot, peningkatan, dan kandungan fail usang semasa iterasi versi',
|
||||
panelOriginal: 'Fail sandaran pemulihan snapshot sistem',
|
||||
backup: 'Direktori sandaran sementara',
|
||||
upgrade: 'Fail sandaran peningkatan sistem',
|
||||
upgradeHelper: '(Disarankan untuk mengekalkan sandaran peningkatan terbaru untuk pemulihan sistem)',
|
||||
cache: 'Fail cache sistem',
|
||||
cacheHelper: '(Berhati-hati, pembersihan memerlukan permulaan semula perkhidmatan)',
|
||||
snapshotTmp: 'Fail sementara muat naik snapshot sistem',
|
||||
snapshotLocal: 'Fail sementara ciptaan snapshot sistem',
|
||||
rollback: 'Fail sandaran sebelum pemulihan',
|
||||
unused: 'Direktori sistem yang tidak digunakan',
|
||||
oldUpgrade: 'Direktori sandaran sebelum peningkatan yang tidak digunakan',
|
||||
oldOriginal: 'Direktori sandaran pemulihan snapshot yang tidak digunakan',
|
||||
oldAppsBak: 'Direktori sandaran aplikasi yang tidak digunakan',
|
||||
|
||||
upload: 'Fail Muat Naik Sementara',
|
||||
uploadHelper: 'Fail sementara dimuat naik dari senarai sandaran sistem',
|
||||
|
|
|
|||
|
|
@ -1989,17 +1989,12 @@ const message = {
|
|||
systemHelper:
|
||||
'Arquivos temporários gerados durante snapshots, atualizações e conteúdos obsoletos durante iterações de versão',
|
||||
panelOriginal: 'Arquivos de backup de recuperação de snapshot do sistema',
|
||||
backup: 'Diretório de backup temporário',
|
||||
upgrade: 'Arquivos de backup de atualização do sistema',
|
||||
upgradeHelper: '(Recomenda-se manter o backup de atualização mais recente para rollback do sistema)',
|
||||
cache: 'Arquivos de cache do sistema',
|
||||
cacheHelper: '(Prossiga com cautela, a limpeza exige reinício do serviço)',
|
||||
snapshotTmp: 'Arquivos temporários de upload de snapshot do sistema',
|
||||
snapshotLocal: 'Arquivos temporários de criação de snapshot do sistema',
|
||||
rollback: 'Arquivos de backup antes da recuperação',
|
||||
unused: 'Diretórios do sistema não utilizados',
|
||||
oldUpgrade: 'Diretórios de backup não utilizados anteriores à atualização',
|
||||
oldOriginal: 'Diretórios de backup de recuperação de snapshot não utilizados',
|
||||
oldAppsBak: 'Diretórios de backup de aplicativos não utilizados',
|
||||
|
||||
upload: 'Arquivos temporários de upload',
|
||||
uploadHelper: 'Arquivos temporários enviados da lista de backup do sistema',
|
||||
|
|
|
|||
|
|
@ -1984,17 +1984,12 @@ const message = {
|
|||
systemHelper:
|
||||
'Временные файлы, созданные во время снапшотов, обновлений, и устаревшее содержимое файлов при итерациях версий',
|
||||
panelOriginal: 'Файлы резервных копий восстановления системных снапшотов',
|
||||
backup: 'Временный резервный каталог',
|
||||
upgrade: 'Файлы резервных копий системных обновлений',
|
||||
upgradeHelper: '(Рекомендуется сохранять последнюю резервную копию обновления для отката системы)',
|
||||
cache: 'Системные файлы кэша',
|
||||
cacheHelper: '(Действуйте с осторожностью, очистка требует перезапуска службы)',
|
||||
snapshotTmp: 'Временные файлы загрузки системных снапшотов',
|
||||
snapshotLocal: 'Временные файлы создания системных снапшотов',
|
||||
rollback: 'Файлы резервных копий перед восстановлением',
|
||||
unused: 'Неиспользуемые системные директории',
|
||||
oldUpgrade: 'Неиспользуемые директории резервных копий перед обновлением',
|
||||
oldOriginal: 'Неиспользуемые директории резервных копий перед восстановлением снапшотов',
|
||||
oldAppsBak: 'Неиспользуемые директории резервных копий приложений',
|
||||
|
||||
upload: 'Временные файлы загрузки',
|
||||
uploadHelper: 'Временные файлы, загруженные из списка системных резервных копий',
|
||||
|
|
|
|||
|
|
@ -2044,18 +2044,13 @@ const message = {
|
|||
systemHelper:
|
||||
'Anlık görüntüler, yükseltmeler ve sürüm iterasyonları sırasında eski dosya içerikleri sırasında üretilen geçici dosyalar',
|
||||
panelOriginal: 'Sistem anlık görüntü kurtarma yedek dosyaları',
|
||||
backup: 'Geçici yedekleme dizini',
|
||||
upgrade: 'Sistem yükseltme yedek dosyaları',
|
||||
upgradeHelper: '(Sistem geri alımı için en son yükseltme yedeğini tutmanız önerilir)',
|
||||
cache: 'Sistem önbellek dosyaları',
|
||||
cacheHelper: '(Dikkatli ilerleyin, temizleme servis yeniden başlatılmasını gerektirir)',
|
||||
snapshot: 'Sistem anlık görüntü geçici dosyaları',
|
||||
snapshotTmp: 'Sistem anlık görüntü yükleme geçici dosyaları',
|
||||
snapshotLocal: 'Sistem anlık görüntü oluşturma geçici dosyaları',
|
||||
rollback: 'Kurtarma öncesi yedek dosyaları',
|
||||
unused: 'Kullanılmayan sistem dizinleri',
|
||||
oldUpgrade: 'Kullanılmayan yükseltme öncesi yedek dizinler',
|
||||
oldOriginal: 'Kullanılmayan anlık görüntü kurtarma öncesi yedek dizinler',
|
||||
oldAppsBak: 'Kullanılmayan uygulama yedek dizinleri',
|
||||
|
||||
upload: 'Geçici Yükleme Dosyaları',
|
||||
uploadHelper: 'Sistem yedek listesinden yüklenen geçici dosyalar',
|
||||
|
|
|
|||
|
|
@ -1891,18 +1891,13 @@ const message = {
|
|||
system: '系統垃圾',
|
||||
systemHelper: '快照、升級等過程中產生的臨時文件以及版本叠代過程中廢棄的文件內容',
|
||||
panelOriginal: '系統快照恢復前備份文件',
|
||||
backup: '臨時備份目錄',
|
||||
upgrade: '系統升級備份文件',
|
||||
upgradeHelper: '( 建議保留最新的升級備份用於系統回滾 )',
|
||||
cache: '系統緩存文件',
|
||||
cacheHelper: '( 謹慎操作,清理需要重啟服務 )',
|
||||
snapshot: '系統快照臨時文件',
|
||||
snapshotTmp: '系統快照上傳臨時文件',
|
||||
snapshotLocal: '系統快照製作臨時文件',
|
||||
rollback: '恢復前備份目錄',
|
||||
unused: '系統廢棄目錄',
|
||||
oldUpgrade: '廢棄升級前備份目錄',
|
||||
oldOriginal: '廢棄快照恢復前備份目錄',
|
||||
oldAppsBak: '廢棄應用備份目錄',
|
||||
|
||||
upload: '臨時上傳文件',
|
||||
uploadHelper: '系統上傳備份列表中上傳的臨時文件',
|
||||
|
|
|
|||
|
|
@ -1881,18 +1881,13 @@ const message = {
|
|||
system: '系统垃圾',
|
||||
systemHelper: '快照、升级等过程中产生的临时文件以及版本迭代过程中废弃的文件内容',
|
||||
panelOriginal: '系统快照恢复前备份文件',
|
||||
backup: '临时备份目录',
|
||||
upgrade: '系统升级备份文件',
|
||||
upgradeHelper: '( 建议保留最新的升级备份用于系统回滚 )',
|
||||
cache: '系统缓存文件',
|
||||
cacheHelper: '( 谨慎操作,清理需要重启服务 )',
|
||||
snapshot: '系统快照临时文件',
|
||||
snapshotTmp: '系统快照上传临时文件',
|
||||
snapshotLocal: '系统快照制作临时文件',
|
||||
rollback: '恢复前备份目录',
|
||||
unused: '系统废弃目录',
|
||||
oldUpgrade: '废弃升级前备份目录',
|
||||
oldOriginal: '废弃快照恢复前备份目录',
|
||||
oldAppsBak: '废弃应用备份目录',
|
||||
|
||||
upload: '临时上传文件',
|
||||
uploadHelper: '系统上传备份列表中上传的临时文件',
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ const toolboxRouter = {
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'fail2Ban',
|
||||
path: 'fail2ban',
|
||||
name: 'Fail2ban',
|
||||
component: () => import('@/views/toolbox/fail2ban/index.vue'),
|
||||
hidden: true,
|
||||
|
|
|
|||
|
|
@ -166,6 +166,7 @@
|
|||
:props="defaultProps"
|
||||
@check-change="onChange"
|
||||
class="responsive-tree"
|
||||
:empty-text="$t('clean.statusEmpty')"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="tree-node">
|
||||
|
|
@ -203,6 +204,7 @@
|
|||
:props="defaultProps"
|
||||
@check-change="onChange"
|
||||
class="responsive-tree"
|
||||
:empty-text="$t('clean.statusEmpty')"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="tree-node">
|
||||
|
|
@ -239,6 +241,7 @@
|
|||
:props="defaultProps"
|
||||
@check-change="onChange"
|
||||
class="responsive-tree"
|
||||
:empty-text="$t('clean.statusEmpty')"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="tree-node">
|
||||
|
|
@ -275,6 +278,7 @@
|
|||
:props="defaultProps"
|
||||
@check-change="onChange"
|
||||
class="responsive-tree"
|
||||
:empty-text="$t('clean.statusEmpty')"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="tree-node">
|
||||
|
|
@ -311,6 +315,7 @@
|
|||
:props="defaultProps"
|
||||
@check-change="onChange"
|
||||
class="responsive-tree"
|
||||
:empty-text="$t('clean.statusEmpty')"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<div class="tree-node">
|
||||
|
|
@ -595,26 +600,16 @@ function load18n(label: string) {
|
|||
switch (label) {
|
||||
case '1panel_original':
|
||||
return i18n.global.t('clean.panelOriginal');
|
||||
case 'backup':
|
||||
return i18n.global.t('clean.backup');
|
||||
case 'upgrade':
|
||||
return i18n.global.t('clean.upgrade');
|
||||
case 'cache':
|
||||
return i18n.global.t('clean.cache');
|
||||
case 'snapshot':
|
||||
return i18n.global.t('clean.snapshot');
|
||||
case 'snapshot_tmp':
|
||||
return i18n.global.t('clean.snapshotTmp');
|
||||
case 'snapshot_local':
|
||||
return i18n.global.t('clean.snapshotLocal');
|
||||
case 'rollback':
|
||||
return i18n.global.t('clean.rollback');
|
||||
case 'unused':
|
||||
return i18n.global.t('clean.unused');
|
||||
case 'old_original':
|
||||
return i18n.global.t('clean.oldOriginal');
|
||||
case 'old_apps_bak':
|
||||
return i18n.global.t('clean.oldAppsBak');
|
||||
case 'old_upgrade':
|
||||
return i18n.global.t('clean.oldUpgrade');
|
||||
case 'upload':
|
||||
case 'upload_tmp':
|
||||
return i18n.global.t('clean.upload');
|
||||
|
|
@ -622,20 +617,25 @@ function load18n(label: string) {
|
|||
return i18n.global.t('clean.download');
|
||||
case 'upload_website':
|
||||
case 'rollback_website':
|
||||
case 'tmp_backup_website':
|
||||
case 'download_website':
|
||||
return i18n.global.t('menu.website');
|
||||
case 'upload_app':
|
||||
case 'rollback_app':
|
||||
case 'tmp_backup_app':
|
||||
case 'download_app':
|
||||
return i18n.global.t('app.app');
|
||||
case 'upload_database':
|
||||
case 'rollback_database':
|
||||
case 'tmp_backup_database':
|
||||
case 'download_database':
|
||||
return i18n.global.t('menu.database');
|
||||
case 'upload_directory':
|
||||
case 'tmp_backup_directory':
|
||||
case 'download_directory':
|
||||
return i18n.global.t('clean.directory');
|
||||
case 'system_log':
|
||||
case 'tmp_backup_log':
|
||||
return i18n.global.t('clean.systemLog');
|
||||
case 'script':
|
||||
return i18n.global.t('cronjob.library.script');
|
||||
|
|
@ -663,6 +663,7 @@ function load18n(label: string) {
|
|||
case 'Image':
|
||||
return i18n.global.t('container.image');
|
||||
case 'Snapshot':
|
||||
case 'tmp_backup_snapshot':
|
||||
return i18n.global.t('setting.snapshot');
|
||||
case 'AppStore':
|
||||
return i18n.global.t('menu.apps');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue