Dont rm directories with -G unless using -f

This commit is contained in:
morganamilo 2018-08-30 15:30:52 +01:00
parent 070f103fb9
commit 004595a396
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
2 changed files with 34 additions and 5 deletions

View file

@ -158,9 +158,29 @@ func getPkgbuilds(pkgs []string) error {
} }
if len(aur) > 0 { if len(aur) > 0 {
bases := getBases(info) allBases := getBases(info)
toSkip := pkgbuildsToSkip(bases, nil) bases := make([]Base, 0)
if _, err = downloadPkgbuilds(bases, toSkip, wd); err != nil {
for _, base := range allBases {
name := base.Pkgbase()
_, err = os.Stat(filepath.Join(wd, name))
if err != nil && !os.IsNotExist(err) {
fmt.Println(bold(red(smallArrow)), err)
continue
} else if os.IsNotExist(err) || cmdArgs.existsArg("f", "force") || shouldUseGit(filepath.Join(wd, name)) {
if err = os.RemoveAll(filepath.Join(wd, name)); err != nil {
fmt.Println(bold(red(smallArrow)), err)
continue
}
} else {
fmt.Printf("%s %s %s\n", yellow(smallArrow), cyan(name), "already downloaded -- use -f to overwrite")
continue
}
bases = append(bases, base)
}
if _, err = downloadPkgbuilds(bases, nil, wd); err != nil {
return err return err
} }
@ -227,9 +247,18 @@ func getPkgbuildsfromABS(pkgs []string, path string) (bool, error) {
continue continue
} }
if err = os.RemoveAll(filepath.Join(path, name)); err != nil { _, err = os.Stat(filepath.Join(path, name))
if err != nil && !os.IsNotExist(err) {
fmt.Println(bold(red(smallArrow)), err) fmt.Println(bold(red(smallArrow)), err)
continue continue
} else if os.IsNotExist(err) || cmdArgs.existsArg("f", "force") {
if err = os.RemoveAll(filepath.Join(path, name)); err != nil {
fmt.Println(bold(red(smallArrow)), err)
continue
}
} else {
fmt.Printf("%s %s %s\n", yellow(smallArrow), cyan(name), "already downloaded -- use -f to overwrite")
continue
} }
names[name] = url names[name] = url

View file

@ -389,7 +389,7 @@ func isArg(arg string) bool {
case "ignoregroup": case "ignoregroup":
case "needed": case "needed":
case "overwrite": case "overwrite":
case "force": case "f", "force":
case "c", "changelog": case "c", "changelog":
case "deps": case "deps":
case "e", "explicit": case "e", "explicit":