diff --git a/agent/app/service/device_clean.go b/agent/app/service/device_clean.go index 87b455194..bef3b3629 100644 --- a/agent/app/service/device_clean.go +++ b/agent/app/service/device_clean.go @@ -194,6 +194,8 @@ func (u *DeviceService) Clean(req []dto.Clean) { _, _ = dropVolumes() case "build_cache": _, _ = dropBuildCache() + case "app_tmp_download_version": + dropFileOrDir(path.Join(global.Dir.RemoteAppResourceDir, item.Name)) } } @@ -612,6 +614,22 @@ func loadDownloadTree(fileOp fileUtils.FileOp) []dto.CleanTree { uploadTreeData := loadTreeWithAllFile(true, path5, "download", path5, fileOp) treeData = append(treeData, uploadTreeData...) + appTmpDownloadTree := loadAppTmpDownloadTree(fileOp) + if len(appTmpDownloadTree) > 0 { + parentTree := dto.CleanTree{ + ID: uuid.NewString(), + Label: "app_tmp_download", + IsCheck: true, + IsRecommend: true, + Type: "app_tmp_download", + Name: "apps", + } + for _, child := range appTmpDownloadTree { + parentTree.Size += child.Size + } + parentTree.Children = appTmpDownloadTree + treeData = append(treeData, parentTree) + } return treeData } @@ -665,6 +683,70 @@ func loadWebsiteLogTree(fileOp fileUtils.FileOp) []dto.CleanTree { return res } +func loadAppTmpDownloadTree(fileOp fileUtils.FileOp) []dto.CleanTree { + appDirs, err := os.ReadDir(global.Dir.RemoteAppResourceDir) + if err != nil { + return nil + } + var res []dto.CleanTree + for _, appDir := range appDirs { + if !appDir.IsDir() { + continue + } + appKey := appDir.Name() + app, _ := appRepo.GetFirst(appRepo.WithKey(appKey)) + if app.ID == 0 { + continue + } + appPath := filepath.Join(global.Dir.RemoteAppResourceDir, appKey) + versionDirs, err := os.ReadDir(appPath) + if err != nil { + continue + } + appDetails, _ := appDetailRepo.GetBy(appDetailRepo.WithAppId(app.ID)) + existingVersions := make(map[string]bool) + for _, appDetail := range appDetails { + existingVersions[appDetail.Version] = true + } + var missingVersions []string + for _, versionDir := range versionDirs { + if !versionDir.IsDir() { + continue + } + + version := versionDir.Name() + if !existingVersions[version] { + missingVersions = append(missingVersions, version) + } + } + if len(missingVersions) > 0 { + var appTree dto.CleanTree + appTree.ID = uuid.NewString() + appTree.Label = app.Name + appTree.Type = "app_tmp_download" + appTree.Name = appKey + appTree.IsRecommend = true + appTree.IsCheck = true + for _, version := range missingVersions { + versionPath := filepath.Join(appPath, version) + size, _ := fileOp.GetDirSize(versionPath) + appTree.Size += uint64(size) + appTree.Children = append(appTree.Children, dto.CleanTree{ + ID: uuid.NewString(), + Label: version, + Size: uint64(size), + IsCheck: true, + IsRecommend: true, + Type: "app_tmp_download_version", + Name: path.Join(appKey, version), + }) + } + res = append(res, appTree) + } + } + return res +} + func loadContainerTree() []dto.CleanTree { var treeData []dto.CleanTree client, err := docker.NewDockerClient() @@ -786,7 +868,7 @@ func loadTreeWithAllFile(isCheck bool, originalPath, treeType, pathItem string, ID: uuid.NewString(), Label: file.Name(), Type: treeType, - Size: uint64(size), + Size: size, Name: name, IsCheck: isCheck, IsRecommend: isCheck, diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index a98359a93..85af4f084 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -2233,6 +2233,8 @@ const message = { dockerHelper: 'Files such as containers, images, volumes, build cache, etc.', volumes: 'Volumes', buildCache: 'Container Build Cache', + + appTmpDownload: 'App temporary download file', }, app: { app: 'Application | Applications', diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts index 9a04f66ec..41685435a 100644 --- a/frontend/src/lang/modules/es-es.ts +++ b/frontend/src/lang/modules/es-es.ts @@ -2246,6 +2246,8 @@ const message = { dockerHelper: 'Archivos como contenedores, imágenes, volúmenes, caché de construcción, etc.', volumes: 'Volúmenes', buildCache: 'Caché de build de contenedores', + + appTmpDownload: 'Archivo de descarga temporal de la aplicación', }, app: { app: 'Aplicación | Aplicaciones', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 03b20e7e7..7910bd62b 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -2153,6 +2153,8 @@ const message = { dockerHelper: 'コンテナ、イメージ、ボリューム、ビルドキャッシュなどのファイル', volumes: 'ボリューム', buildCache: 'コンテナビルドキャッシュ', + + appTmpDownload: 'Archivo de descarga temporal de la aplicación', }, app: { app: 'アプリケーション|アプリケーション', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 6fa6eabb4..9d7026469 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -2117,6 +2117,8 @@ const message = { dockerHelper: '컨테이너, 이미지, 볼륨, 빌드 캐시 등의 파일', volumes: '볼륨', buildCache: '컨테이너 빌드 캐시', + + appTmpDownload: '앱 임시 다운로드 파일', }, app: { app: '애플리케이션 | 애플리케이션들', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 5feb264fb..039e57784 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -2212,6 +2212,8 @@ const message = { dockerHelper: 'Fail seperti bekas, imej, isipadu, cache binaan, dsb.', volumes: 'Isipadu', buildCache: 'Cache Pembinaan Kontena', + + appTmpDownload: 'Fail muat turun sementara aplikasi', }, app: { app: 'Aplikasi | Aplikasi', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index 5249b2123..cac1b80ac 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -2206,6 +2206,8 @@ const message = { dockerHelper: 'Arquivos como contêineres, imagens, volumes, cache de compilação, etc.', volumes: 'Volumes', buildCache: 'Cache de construção do container', + + appTmpDownload: 'Arquivo de download temporário do aplicativo', }, app: { app: 'Aplicativo | Aplicativos', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index dd6ed2c50..019c03e3a 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -2201,6 +2201,8 @@ const message = { dockerHelper: 'Файлы, такие как контейнеры, образы, тома, кэш сборки и т.д.', volumes: 'Тома', buildCache: 'Кэш сборки контейнеров', + + appTmpDownload: 'Временный файл загрузки приложения', }, app: { app: 'Приложение | Приложения', diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts index de80f453e..7e7385d8b 100644 --- a/frontend/src/lang/modules/tr.ts +++ b/frontend/src/lang/modules/tr.ts @@ -2258,6 +2258,8 @@ const message = { dockerHelper: 'Konteynerler, görüntüler, hacimler, derleme önbelleği vb. dosyalar', volumes: 'Birimler', buildCache: 'Konteyner Oluşturma Önbelleği', + + appTmpDownload: 'Uygulama geçici indirme dosyası', }, app: { app: 'Uygulama | Uygulamalar', diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts index 9b3220bfc..36279f049 100644 --- a/frontend/src/lang/modules/zh-Hant.ts +++ b/frontend/src/lang/modules/zh-Hant.ts @@ -2082,6 +2082,8 @@ const message = { dockerHelper: '容器、映像、儲存卷、建置快取等檔案', volumes: '磁碟區', buildCache: '容器建置快取', + + appTmpDownload: '應用程式暫存下載檔案', }, app: { app: '應用', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 1277c8315..0d86660c0 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -2079,6 +2079,8 @@ const message = { dockerHelper: '容器、镜像、存储卷、构建缓存等文件', volumes: '存储卷', buildCache: '构建缓存', + + appTmpDownload: '应用临时下载文件', }, app: { app: '应用', diff --git a/frontend/src/views/toolbox/clean/index.vue b/frontend/src/views/toolbox/clean/index.vue index 6015d08fa..944405ca3 100644 --- a/frontend/src/views/toolbox/clean/index.vue +++ b/frontend/src/views/toolbox/clean/index.vue @@ -422,13 +422,15 @@ const loadSubmitCheck = (data: any) => { } return; } + for (const item of data) { if ( item.isCheck && item.label !== 'unknown_app' && item.label !== 'unknown_database' && item.label !== 'unknown_website' && - item.label !== 'unknown_snapshot' + item.label !== 'unknown_snapshot' && + item.type !== 'app_tmp_download' ) { submitCleans.value.push({ treeType: item.type, name: item.name, size: item.size }); continue; @@ -632,6 +634,8 @@ function load18n(label: string) { return i18n.global.t('clean.buildCache'); case 'website_log': return i18n.global.t('logs.websiteLog'); + case 'app_tmp_download': + return i18n.global.t('clean.appTmpDownload'); default: return label; }