feat: Enhance backup details display and support for scheduled backups in directory loading

This commit is contained in:
Peter Wood
2025-06-01 21:33:26 -04:00
parent c38dd066f7
commit b94c41f3f2
2 changed files with 19 additions and 5 deletions

View File

@@ -819,6 +819,12 @@ func (m *Model) showBackupDetails(details BackupDetails) {
// Directory summary
content.WriteString("📊 Directory Summary:\n")
content.WriteString(fmt.Sprintf(" 📁 Path: %s\n", details.Directory.Path))
// Show if this is using a scheduled subfolder
if strings.HasSuffix(details.Directory.Path, "/scheduled") {
content.WriteString(" 📅 Source: Scheduled backups (from 'scheduled' subfolder)\n")
}
content.WriteString(fmt.Sprintf(" 📄 Files: %d\n", details.TotalFiles))
content.WriteString(fmt.Sprintf(" 💾 Total Size: %s\n", formatSize(details.TotalSize)))
@@ -925,9 +931,17 @@ func formatSize(bytes int64) string {
// loadBackupDirectory loads backup files from a directory
func (m *Model) loadBackupDirectory(dirPath string) tea.Cmd {
return func() tea.Msg {
files, err := os.ReadDir(dirPath)
// Check if there's a "scheduled" subfolder - if so, use that instead
scheduledPath := filepath.Join(dirPath, "scheduled")
actualPath := dirPath
if info, err := os.Stat(scheduledPath); err == nil && info.IsDir() {
actualPath = scheduledPath
}
files, err := os.ReadDir(actualPath)
if err != nil {
return errorMsg{error: fmt.Sprintf("Failed to read directory %s: %v", dirPath, err)}
return errorMsg{error: fmt.Sprintf("Failed to read directory %s: %v", actualPath, err)}
}
var backupFiles []BackupFile
@@ -946,11 +960,11 @@ func (m *Model) loadBackupDirectory(dirPath string) tea.Cmd {
backupFile := BackupFile{
Name: file.Name(),
Path: filepath.Join(dirPath, file.Name()),
Path: filepath.Join(actualPath, file.Name()),
Size: info.Size(),
ModifiedTime: info.ModTime(),
IsCompressed: strings.HasSuffix(file.Name(), ".tar.gz") || strings.HasSuffix(file.Name(), ".zip"),
Service: filepath.Base(dirPath),
Service: filepath.Base(dirPath), // Keep using original dirPath for service name
}
backupFiles = append(backupFiles, backupFile)
@@ -975,7 +989,7 @@ func (m *Model) loadBackupDirectory(dirPath string) tea.Cmd {
details := BackupDetails{
Directory: BackupDirectory{
Name: filepath.Base(dirPath),
Path: dirPath,
Path: actualPath, // Show the actual path where files are located
FileCount: len(backupFiles),
TotalSize: totalSize,
LastModified: lastModified,