From 1b3cca2815e8d8c3aa3fa11ed6cdccd7eae0421e Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sat, 2 Jun 2018 15:18:38 +0300 Subject: Abort sync operation if "--refresh" fails --- src/feature/syncsource.nim | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'src/feature/syncsource.nim') 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) -- cgit v1.2.3-70-g09d2