1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 01:06:50 +00:00

RemoteRepository: clean up pipe if remote open() fails

This commit is contained in:
Marian Beermann 2016-04-03 21:44:29 +02:00
parent 425a4d819d
commit 890e44ef60

View file

@ -81,6 +81,7 @@ def serve(self):
unpacker.feed(data)
for unpacked in unpacker:
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
self.repository.close()
raise Exception("Unexpected RPC data format.")
type, msgid, method, args = unpacked
method = method.decode('ascii')
@ -165,7 +166,11 @@ def __init__(self, location, create=False, lock_wait=None, lock=True, args=None)
raise ConnectionClosedWithHint('Is borg working on the server?') from None
if version != RPC_PROTOCOL_VERSION:
raise Exception('Server insisted on using unsupported protocol version %d' % version)
self.id = self.call('open', location.path, create, lock_wait, lock)
try:
self.id = self.call('open', self.location.path, create, lock_wait, lock)
except Exception:
self.close()
raise
def __del__(self):
self.close()