Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2015-03-15 16:32:56 +1000
committerAllan McRae <allan@archlinux.org>2015-03-26 14:43:37 +1000
commit81d233b79345d05d5bf17a4b2844085e14f9ee36 (patch)
tree8267ba1f224a31d6ee3ce304fdc51e81f130aaab
parentd2cb52de12d3b2f313d80156f474b1d731ad67cf (diff)
repo-add: only update database if entire command succeeded
It is not hard to think of situations where the repo database should not be updated unless the whole operation succeeds. Error out before a partial database update occurs. Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--scripts/repo-add.sh.in8
1 files changed, 4 insertions, 4 deletions
diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 2d9b2628..d4963543 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -688,7 +688,6 @@ trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
declare -a args
-success=0
# parse arguments
while (( $# )); do
case $1 in
@@ -737,15 +736,16 @@ if (( SIGN || KEY || VERIFY )); then
check_gpg
fi
+fail=0
for arg in "${args[@]:1}"; do
case $cmd in
repo-add) add "$arg" ;;
repo-remove) remove "$arg" ;;
- esac && success=1
+ esac || fail=1
done
-# if at least one operation was a success, re-zip database
-if (( success )); then
+# if the whole operation was a success, re-zip and rotate database
+if (( !fail )); then
msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
create_db
rotate_db