From c22b4c99ba4e66dcbf97ce0fb4b6c38372e20be6 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 26 Oct 2026 16:32:48 -0400 Subject: Handle ^C gracefully during wget downloads. --- TODO | 4 ---- greypool | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 4b7114a..4672246 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,8 @@ TODO list for greypool -- color and pager options for the config file. - - handle the case where a project has more than one maintainer... or no maintainer. this doesn't happen with SlackBuilds.org. -- handle ^C gracefully during wget downloads. - - improve the interactive config: - cache the repo list? - possibly use dialog? diff --git a/greypool b/greypool index 8cb8281..8be422a 100755 --- a/greypool +++ b/greypool @@ -562,6 +562,10 @@ sub stamp_cache { sub check_cache { mkdir_p $cachedir; return if cache_ok() || $no_download; + invalidate_cache(); +} + +sub invalidate_cache { for(<$cachedir/*>) { unlink $_; } @@ -603,8 +607,13 @@ sub download { "'$url'"; debug $cmd; + + $SIG{INT} = sub { invalidate_cache(); fatal "exiting due to ^C"; exit 1; }; my $status = system($cmd); + $SIG{INT} = 'DEFAULT'; + if($status) { + invalidate_cache(); fatal "wget failed, exit status " . ($status >> 8); } sleep 1; # repology wants to limit requests to 1 per sec. -- cgit v1.2.3