mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 00:00:13 -08:00
feat: Enhance backup details display and support for scheduled backups in directory loading
This commit is contained in:
BIN
tui/backup-tui
BIN
tui/backup-tui
Binary file not shown.
24
tui/main.go
24
tui/main.go
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user