diff options
author | kitsunyan | 2018-06-02 12:18:38 +0000 |
---|---|---|
committer | kitsunyan | 2018-06-02 12:18:38 +0000 |
commit | 1b3cca2815e8d8c3aa3fa11ed6cdccd7eae0421e (patch) | |
tree | b38ef720bde5279c1cec47844e5cada3003970f4 /src/feature/syncsource.nim | |
parent | 3d420e1b546c5636e38653cb21d5dc0f4306a30a (diff) |
Abort sync operation if "--refresh" fails
Diffstat (limited to 'src/feature/syncsource.nim')
-rw-r--r-- | src/feature/syncsource.nim | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim index 8096f02..5c3f35a 100644 --- a/src/feature/syncsource.nim +++ b/src/feature/syncsource.nim @@ -153,28 +153,30 @@ proc cloneAndCopy(config: Config, quiet: bool, 0 proc handleSyncSource*(args: seq[Argument], config: Config): int = - discard checkAndRefresh(config.color, args) - - let quiet = args.check(%%%"quiet") - let targets = args.packageTargets(true) - - if targets.len == 0: - printError(config.color, trp("no targets specified (use -h for help)\n")) - 1 + let (refreshCode, _) = checkAndRefresh(config.color, args) + if refreshCode != 0: + refreshCode else: - let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors): - for e in errors: printError(config.color, e) - findSyncTargets(handle, dbs, targets, false, false) - - let (rpcInfos, aerrors) = getRpcPackageInfos(checkAurNames) - for e in aerrors: printError(config.color, e) - - let notFoundTargets = filterNotFoundSyncTargets(syncTargets, - rpcInfos, initTable[string, PackageReference]()) + let quiet = args.check(%%%"quiet") + let targets = args.packageTargets(true) - if notFoundTargets.len > 0: - printSyncNotFound(config, notFoundTargets) + if targets.len == 0: + printError(config.color, trp("no targets specified (use -h for help)\n")) 1 else: - let fullTargets = mapAurTargets[RpcPackageInfo](syncTargets, rpcInfos) - cloneAndCopy(config, quiet, fullTargets) + let (syncTargets, checkAurNames) = withAlpmConfig(config, true, handle, dbs, errors): + for e in errors: printError(config.color, e) + findSyncTargets(handle, dbs, targets, false, false) + + let (rpcInfos, aerrors) = getRpcPackageInfos(checkAurNames) + for e in aerrors: printError(config.color, e) + + let notFoundTargets = filterNotFoundSyncTargets(syncTargets, + rpcInfos, initTable[string, PackageReference]()) + + if notFoundTargets.len > 0: + printSyncNotFound(config, notFoundTargets) + 1 + else: + let fullTargets = mapAurTargets[RpcPackageInfo](syncTargets, rpcInfos) + cloneAndCopy(config, quiet, fullTargets) |