aboutsummaryrefslogtreecommitdiff
path: root/src/feature/syncinfo.nim
diff options
context:
space:
mode:
authorkitsunyan2018-06-02 12:18:38 +0000
committerkitsunyan2018-06-02 12:18:38 +0000
commit1b3cca2815e8d8c3aa3fa11ed6cdccd7eae0421e (patch)
treeb38ef720bde5279c1cec47844e5cada3003970f4 /src/feature/syncinfo.nim
parent3d420e1b546c5636e38653cb21d5dc0f4306a30a (diff)
Abort sync operation if "--refresh" fails
Diffstat (limited to 'src/feature/syncinfo.nim')
-rw-r--r--src/feature/syncinfo.nim43
1 files changed, 23 insertions, 20 deletions
diff --git a/src/feature/syncinfo.nim b/src/feature/syncinfo.nim
index fc1510b..2de5bda 100644
--- a/src/feature/syncinfo.nim
+++ b/src/feature/syncinfo.nim
@@ -100,29 +100,32 @@ proc handleTarget(config: Config, padding: int, args: seq[Argument],
pacmanRun(false, config.color, args & ($target, none(string), ArgumentType.target))
proc handleSyncInfo*(args: seq[Argument], config: Config): int =
- let (_, callArgs) = checkAndRefresh(config.color, args)
- let targets = args.packageTargets(false)
+ let (refreshCode, callArgs) = checkAndRefresh(config.color, args)
+ if refreshCode != 0:
+ refreshCode
+ else:
+ let targets = args.packageTargets(false)
- let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
- for e in errors: printError(config.color, e)
- findSyncTargets(handle, dbs, targets, false, false)
+ let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors):
+ for e in errors: printError(config.color, e)
+ findSyncTargets(handle, dbs, targets, false, false)
- let (pkgInfos, _, aerrors) = getAurPackageInfos(checkAurNames, config.arch)
- for e in aerrors: printError(config.color, e)
+ let (pkgInfos, _, aerrors) = getAurPackageInfos(checkAurNames, config.arch)
+ for e in aerrors: printError(config.color, e)
- let fullTargets = mapAurTargets[PackageInfo](syncTargets, pkgInfos)
+ let fullTargets = mapAurTargets[PackageInfo](syncTargets, pkgInfos)
- let code = min(aerrors.len, 1)
- if fullTargets.filter(t => isAurTargetFull[PackageInfo](t) or t.repo == some("aur")).len == 0 and
- fullTargets.filter(t => t.reference.constraint.isSome).len == 0:
- if code == 0:
- pacmanExec(false, config.color, callArgs)
+ let code = min(aerrors.len, 1)
+ if fullTargets.filter(t => isAurTargetFull[PackageInfo](t) or t.repo == some("aur") or
+ t.reference.constraint.isSome).len == 0:
+ if code == 0:
+ pacmanExec(false, config.color, callArgs)
+ else:
+ discard pacmanRun(false, config.color, callArgs)
+ code
else:
- discard pacmanRun(false, config.color, callArgs)
- code
- else:
- let finalArgs = callArgs.filter(arg => not arg.isTarget)
- let padding = pacmanInfoStrings.map(s => s.trp).computeMaxLength
+ let finalArgs = callArgs.filter(arg => not arg.isTarget)
+ let padding = pacmanInfoStrings.map(s => s.trp).computeMaxLength
- let codes = code & lc[handleTarget(config, padding, finalArgs, x) | (x <- fullTargets), int]
- codes.filter(c => c != 0).optFirst.get(0)
+ let codes = code & lc[handleTarget(config, padding, finalArgs, x) | (x <- fullTargets), int]
+ codes.filter(c => c != 0).optFirst.get(0)