Skip to content
Open
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
22 changes: 18 additions & 4 deletions internal/tui/views/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
zone "github.com/lrstanley/bubblezone"
"github.com/pashkov256/deletor/internal/cache"
"github.com/pashkov256/deletor/internal/filemanager"
"github.com/pashkov256/deletor/internal/tui/errors"
"github.com/pashkov256/deletor/internal/tui/help"
"github.com/pashkov256/deletor/internal/tui/options"
"github.com/pashkov256/deletor/internal/tui/styles"
Expand All @@ -26,6 +27,7 @@
scanResults []cache.ScanResult
isScanning bool
status string
Error *errors.Error

Check failure on line 30 in internal/tui/views/cache.go

View workflow job for this annotation

GitHub Actions / Test and Lint

File is not properly formatted (gofmt)
}

type CachePath struct {
Expand Down Expand Up @@ -135,6 +137,14 @@
content.WriteString(styles.InfoStyle.Render(m.status))
}

// Add error message if there is one
if m.Error != nil && m.Error.IsVisible() {
errorStyle := errors.GetStyle(m.Error.GetType())
content.WriteString("\n")
content.WriteString(errorStyle.Render(m.Error.GetMessage()))
}


content.WriteString("\n")
scanBtn := styles.LaunchButtonStyle.Render("🔍 Scan now")
deleteBtn := styles.DeleteButtonStyle.Render("🗑️ Delete selected")
Expand Down Expand Up @@ -252,11 +262,15 @@
if runtime.GOOS == "darwin" {
m.status = "Currently only Windows and linux is supported for cache clearing\n"
} else {
m.cacheManager.ClearCache()
m.scanResults = []cache.ScanResult{}
m.status = "Cache clearing completed\n"
if err := m.cacheManager.ClearCache(); err != nil {
m.Error = errors.New(errors.ErrorTypeFileSystem, fmt.Sprintf("Failed to clear all files: %v", err))
m.status = ""
} else {
m.scanResults = []cache.ScanResult{}
m.status = "Cache clearing completed\n"
m.Error = nil // Clear error on successful deletion
}
}
return m, nil
}
return m, nil
}
Loading