From 10b38789d69612345f3945f6175788be2d655acf Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 15 Jul 2024 00:38:24 +0200 Subject: [PATCH 1/3] delete: fix error handling when no archive is specified, fixes #8256 --- src/borg/archiver/delete_cmd.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/borg/archiver/delete_cmd.py b/src/borg/archiver/delete_cmd.py index 00c3169c8..d00703b4d 100644 --- a/src/borg/archiver/delete_cmd.py +++ b/src/borg/archiver/delete_cmd.py @@ -5,7 +5,7 @@ from ._common import with_repository, Highlander from ..archive import Archive, Statistics from ..cache import Cache from ..constants import * # NOQA -from ..helpers import log_multi, format_archive, sig_int +from ..helpers import log_multi, format_archive, sig_int, CommandError from ..manifest import Manifest from ..logger import create_logger @@ -24,11 +24,10 @@ class DeleteMixIn: if not archive_names: return if args.match_archives is None and args.first == 0 and args.last == 0: - self.print_error( + raise CommandError( "Aborting: if you really want to delete all archives, please use -a 'sh:*' " "or just delete the whole repository (might be much faster)." ) - return if args.forced == 2: deleted = False From 0ae65a08c41bd48480d3141dc3d06c3d675b3e4c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 15 Jul 2024 00:48:22 +0200 Subject: [PATCH 2/3] rcompress: fix error handling with Ctrl-C --- src/borg/archiver/rcompress_cmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/archiver/rcompress_cmd.py b/src/borg/archiver/rcompress_cmd.py index 3d5d358c6..30706dcd6 100644 --- a/src/borg/archiver/rcompress_cmd.py +++ b/src/borg/archiver/rcompress_cmd.py @@ -4,7 +4,7 @@ from collections import defaultdict from ._common import with_repository, Highlander from ..constants import * # NOQA from ..compress import CompressionSpec, ObfuscateSize, Auto, COMPRESSOR_TABLE -from ..helpers import sig_int, ProgressIndicatorPercent +from ..helpers import sig_int, ProgressIndicatorPercent, Error from ..manifest import Manifest @@ -150,7 +150,7 @@ class RCompressMixIn: pi.finish() if sig_int: # Ctrl-C / SIGINT: do not checkpoint (commit) again, we already have a checkpoint in this case. - self.print_error("Got Ctrl-C / SIGINT.") + raise Error("Got Ctrl-C / SIGINT.") elif uncommitted_chunks > 0: checkpoint_func() if args.stats: From 126a346296c66a3a513d26111d49d0312bfc83fc Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 15 Jul 2024 00:49:39 +0200 Subject: [PATCH 3/3] delete: fix error handling with Ctrl-C --- src/borg/archiver/delete_cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borg/archiver/delete_cmd.py b/src/borg/archiver/delete_cmd.py index d00703b4d..7095cda90 100644 --- a/src/borg/archiver/delete_cmd.py +++ b/src/borg/archiver/delete_cmd.py @@ -5,7 +5,7 @@ from ._common import with_repository, Highlander from ..archive import Archive, Statistics from ..cache import Cache from ..constants import * # NOQA -from ..helpers import log_multi, format_archive, sig_int, CommandError +from ..helpers import log_multi, format_archive, sig_int, CommandError, Error from ..manifest import Manifest from ..logger import create_logger