Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion agent/app/service/device_clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,8 @@ const message = {
dockerHelper: 'コンテナ、イメージ、ボリューム、ビルドキャッシュなどのファイル',
volumes: 'ボリューム',
buildCache: 'コンテナビルドキャッシュ',

appTmpDownload: 'Archivo de descarga temporal de la aplicación',
},
app: {
app: 'アプリケーション|アプリケーション',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,8 @@ const message = {
dockerHelper: '컨테이너, 이미지, 볼륨, 빌드 캐시 등의 파일',
volumes: '볼륨',
buildCache: '컨테이너 빌드 캐시',

appTmpDownload: '앱 임시 다운로드 파일',
},
app: {
app: '애플리케이션 | 애플리케이션들',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2201,6 +2201,8 @@ const message = {
dockerHelper: 'Файлы, такие как контейнеры, образы, тома, кэш сборки и т.д.',
volumes: 'Тома',
buildCache: 'Кэш сборки контейнеров',

appTmpDownload: 'Временный файл загрузки приложения',
},
app: {
app: 'Приложение | Приложения',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,8 @@ const message = {
dockerHelper: '容器、映像、儲存卷、建置快取等檔案',
volumes: '磁碟區',
buildCache: '容器建置快取',

appTmpDownload: '應用程式暫存下載檔案',
},
app: {
app: '應用',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,8 @@ const message = {
dockerHelper: '容器、镜像、存储卷、构建缓存等文件',
volumes: '存储卷',
buildCache: '构建缓存',

appTmpDownload: '应用临时下载文件',
},
app: {
app: '应用',
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/views/toolbox/clean/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Loading