(fileOp fileUtils.FileOp)
| 502 | } |
| 503 | |
| 504 | func loadUnknownWebsiteLog(fileOp fileUtils.FileOp) dto.CleanTree { |
| 505 | treeData := dto.CleanTree{ |
| 506 | ID: uuid.NewString(), |
| 507 | Label: "unknown_website_log", |
| 508 | IsCheck: false, |
| 509 | IsRecommend: true, |
| 510 | CanDelete: false, |
| 511 | Type: "unknown_backup", |
| 512 | } |
| 513 | dir := path.Join(global.Dir.LocalBackupDir, "log/website") |
| 514 | websites, _ := websiteRepo.List() |
| 515 | websiteMap := make(map[string]struct{}) |
| 516 | for _, website := range websites { |
| 517 | websiteMap[website.Alias] = struct{}{} |
| 518 | } |
| 519 | |
| 520 | entries, _ := os.ReadDir(dir) |
| 521 | for _, entry := range entries { |
| 522 | if !entry.IsDir() { |
| 523 | continue |
| 524 | } |
| 525 | dirName := entry.Name() |
| 526 | if _, ok := websiteMap[dirName]; !ok { |
| 527 | dirPath := path.Join(dir, dirName) |
| 528 | itemSize, _ := fileOp.GetDirSize(dirPath) |
| 529 | childData := dto.CleanTree{ |
| 530 | ID: uuid.NewString(), |
| 531 | Label: dirName, |
| 532 | IsCheck: true, |
| 533 | IsRecommend: true, |
| 534 | CanDelete: true, |
| 535 | Name: dirPath, |
| 536 | Type: "unknown_backup", |
| 537 | Size: uint64(itemSize), |
| 538 | } |
| 539 | treeData.Size += uint64(itemSize) |
| 540 | treeData.Children = append(treeData.Children, childData) |
| 541 | } |
| 542 | } |
| 543 | if treeData.Size > 0 { |
| 544 | treeData.IsCheck = true |
| 545 | } |
| 546 | return treeData |
| 547 | } |
| 548 | |
| 549 | func loadFileOrDirWithExclude(fileOp fileUtils.FileOp, index uint, dir string, rootTree *dto.CleanTree, excludes []string) error { |
| 550 | index++ |
no test coverage detected