Add safety check for package list validation

This commit is contained in:
AI Bot
2026-05-03 14:30:16 +02:00
committed by Riyyi
parent 38d26fd2d8
commit 5ad29767c9
6 changed files with 57 additions and 10 deletions
+19
View File
@@ -35,6 +35,25 @@ func List() ([]string, error) {
return list, nil
}
func ExplicitList() ([]string, error) {
start := time.Now()
log.Debug("ExplicitList: starting...")
cmd := exec.Command("pacman", "-Qqe")
output, err := cmd.Output()
if err != nil {
return nil, err
}
list := strings.Split(strings.TrimSpace(string(output)), "\n")
if len(list) > 0 && list[0] == "" {
list = nil
}
log.Debug("ExplicitList: done (%.2fs)", time.Since(start).Seconds())
return list, nil
}
func ListOrphans() ([]string, error) {
start := time.Now()
log.Debug("ListOrphans: starting...")