]> arthur.barton.de Git - bup.git/commitdiff
rm: handle writer.abort exceptions when exception pending
authorRob Browning <rlb@defaultvalue.org>
Sat, 12 Sep 2020 22:21:43 +0000 (17:21 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 22 Nov 2020 19:32:57 +0000 (13:32 -0600)
And drop the else clause since it's unnecessary here.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/rm.py

index 3bc2d833e3f853efd20581abdcac065b76312e06..b1f7889870661f2ebece466ae702dd136b970c8f 100644 (file)
@@ -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