[PATCH 4/9] Client.__init__: clean up at the end, even if check_ok() fails

0 views
Skip to first unread message

Rob Browning

unread,
Jan 16, 2022, 3:06:21 PM1/16/22
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

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 <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
[r...@defaultvalue.org: adjust commit message]
Tested-by: Rob Browning <r...@defaultvalue.org>
---
lib/bup/client.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/bup/client.py b/lib/bup/client.py
index 7dcf02b2..c4f2bffb 100644
--- a/lib/bup/client.py
+++ b/lib/bup/client.py
@@ -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):
--
2.30.2

Reply all
Reply to author
Forward
0 new messages