Merge pull request #643 from Morganamilo/cleanmenu

Only print the clean number menu when needed
This commit is contained in:
Anna 2018-08-18 20:53:00 +01:00 committed by GitHub
commit ebc4ef1c33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,7 @@ func install(parser *arguments) error {
}
if config.CleanMenu {
if anyExistInCache(do.Aur) {
askClean := pkgbuildNumberMenu(do.Aur, remoteNamesCache)
toClean, err := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
if err != nil {
@ -183,6 +184,7 @@ func install(parser *arguments) error {
cleanBuilds(toClean)
}
}
toSkip := pkgbuildsToSkip(do.Aur, targets)
cloned, err := downloadPkgbuilds(do.Aur, toSkip, config.BuildDir)
@ -485,6 +487,19 @@ func parsePackageList(dir string) (map[string]string, string, error) {
return pkgdests, version, nil
}
func anyExistInCache(bases []Base) bool {
for _, base := range bases {
pkg := base.Pkgbase()
dir := filepath.Join(config.BuildDir, pkg)
if _, err := os.Stat(dir); !os.IsNotExist(err) {
return true
}
}
return false
}
func pkgbuildNumberMenu(bases []Base, installed stringSet) bool {
toPrint := ""
askClean := false