]> arthur.barton.de Git - bup.git/commitdiff
Client.__init__: clean up at the end, even if check_ok() fails
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 30 Dec 2021 20:31:55 +0000 (21:31 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sat, 1 Jan 2022 20:12:46 +0000 (14:12 -0600)
By the time we reach the check_ok() at the end, there are resources
that should be released if that call fails.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message]
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/client.py

index 7dcf02b2582eb2202cfb6a51054cc35474c6fc2c..c4f2bffb6382bf78505d1aee2403ae1f20e5e7e6 100644 (file)
@@ -115,7 +115,11 @@ class Client:
                 self.conn.write(b'init-dir %s\n' % self.dir)
             else:
                 self.conn.write(b'set-dir %s\n' % self.dir)
-            self.check_ok()
+            try:
+                self.check_ok()
+            except BaseException as ex:
+                with pending_raise(ex):
+                    self.close()
         self.sync_indexes()
 
     def close(self):