aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-05-10 07:00:39 +0000
committermerakor <cem@ckyln.com>2021-05-10 07:00:39 +0000
commitbd020b6a77a59ebe14ba1a44d29239b760ab51df (patch)
tree35baa35e6f3406fd84a01dc17e17b495a4a8066b /src
parentc73369c07f7a21701b5f4801081a92602bda81ca (diff)
downloadcpt-bd020b6a77a59ebe14ba1a44d29239b760ab51df.tar.gz
fix handling of interrupt signals on the download operation
FossilOrigin-Name: dde4df8fc98bbe3b8ad590d50ab4309a746ca0231d1398cbdbead7c1fa91e89f
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 5416efe..930c426 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -43,8 +43,11 @@ trap_set() {
trap pkg_clean EXIT
trap 'pkg_clean; exit 1' INT
;;
- block) trap '' INT ;;
- unset) trap - EXIT INT ;;
+ handle-int)
+ trap pkg_clean INT
+ ;;
+ block) trap '' INT ;;
+ unset) trap - EXIT INT ;;
esac
}
@@ -703,11 +706,18 @@ pkg_sources() {
elif [ -z "${src##*://*}" ]; then
log "$1" "Downloading $src"
+ # We don't want our trap to exit immediately here if we receive an
+ # interrupt, we handle this ourselves.
+ trap_set handle-int
+
curl "$src" -fLo "${src##*/}" || {
rm -f "${src##*/}"
die "$1" "Failed to download $src"
}
+ # Restore original trap value.
+ trap_set cleanup
+
# Local source.
elif [ -f "$repo_dir/$src" ]; then
log "$1" "Found local file '$src'"