From a82f25074c50c30fd57789882ac56152b7661cec Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sat, 12 Sep 2020 17:21:43 -0500 Subject: [PATCH] rm: handle writer.abort exceptions when exception pending And drop the else clause since it's unnecessary here. Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/rm.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/bup/rm.py b/lib/bup/rm.py index 3bc2d83..b1f7889 100644 --- a/lib/bup/rm.py +++ b/lib/bup/rm.py @@ -5,7 +5,7 @@ import sys from bup import compat, git, vfs from bup.client import ClientError -from bup.compat import hexstr +from bup.compat import add_ex_ctx, add_ex_tb, hexstr, pending_raise from bup.git import get_commit_items from bup.helpers import add_error, die_if_errors, log, saved_errors from bup.io import path_msg @@ -116,14 +116,13 @@ def bup_rm(repo, paths, compression=6, verbosity=None): for branch, saves in compat.items(dead_saves): assert(saves) updated_refs[b'refs/heads/' + branch] = rm_saves(saves, writer) - except: + except BaseException as ex: if writer: - writer.abort() - raise - else: - if writer: - # Must close before we can update the ref(s) below. - writer.close() + with pending_raise(ex): + writer.abort() + if writer: + # Must close before we can update the ref(s) below. + writer.close() # Only update the refs here, at the very end, so that if something # goes wrong above, the old refs will be undisturbed. Make an attempt -- 2.39.2