mirror of https://github.com/borgbackup/borg.git
remote: Move open to a normal api stub.
This commit is contained in:
parent
ba553ec628
commit
4854fcef2e
|
@ -345,9 +345,6 @@ class RemoteRepository:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.remote_type = remote_type
|
self.remote_type = remote_type
|
||||||
|
|
||||||
class NoAppendOnlyOnServer(Error):
|
|
||||||
"""Server does not support --append-only."""
|
|
||||||
|
|
||||||
class RPCServerOutdated(Error):
|
class RPCServerOutdated(Error):
|
||||||
"""Borg server is too old for {}. Required version {}"""
|
"""Borg server is too old for {}. Required version {}"""
|
||||||
|
|
||||||
|
@ -412,13 +409,20 @@ class RemoteRepository:
|
||||||
else:
|
else:
|
||||||
raise Exception('Server insisted on using unsupported protocol version %s' % version)
|
raise Exception('Server insisted on using unsupported protocol version %s' % version)
|
||||||
|
|
||||||
try:
|
def do_open():
|
||||||
self.id = self.call('open', {'path': self.location.path, 'create': create, 'lock_wait': lock_wait,
|
self.id = self.open(path=self.location.path, create=create, lock_wait=lock_wait,
|
||||||
'lock': lock, 'exclusive': exclusive, 'append_only': append_only})
|
lock=lock, exclusive=exclusive, append_only=append_only)
|
||||||
except self.RPCError as err:
|
|
||||||
if self.dictFormat or err.remote_type != 'TypeError':
|
if self.dictFormat:
|
||||||
raise
|
do_open()
|
||||||
msg = """\
|
else:
|
||||||
|
# Ugly detection of versions prior to 1.0.7: If open throws it has to be 1.0.6 or lower
|
||||||
|
try:
|
||||||
|
do_open()
|
||||||
|
except self.RPCError as err:
|
||||||
|
if err.remote_type != 'TypeError':
|
||||||
|
raise
|
||||||
|
msg = """\
|
||||||
Please note:
|
Please note:
|
||||||
If you see a TypeError complaining about the number of positional arguments
|
If you see a TypeError complaining about the number of positional arguments
|
||||||
given to open(), you can ignore it if it comes from a borg version < 1.0.7.
|
given to open(), you can ignore it if it comes from a borg version < 1.0.7.
|
||||||
|
@ -426,13 +430,12 @@ This TypeError is a cosmetic side effect of the compatibility code borg
|
||||||
clients >= 1.0.7 have to support older borg servers.
|
clients >= 1.0.7 have to support older borg servers.
|
||||||
This problem will go away as soon as the server has been upgraded to 1.0.7+.
|
This problem will go away as soon as the server has been upgraded to 1.0.7+.
|
||||||
"""
|
"""
|
||||||
# emit this msg in the same way as the 'Remote: ...' lines that show the remote TypeError
|
# emit this msg in the same way as the 'Remote: ...' lines that show the remote TypeError
|
||||||
sys.stderr.write(msg)
|
sys.stderr.write(msg)
|
||||||
if append_only:
|
self.server_version = parse_version('1.0.6')
|
||||||
raise self.NoAppendOnlyOnServer()
|
compatMap['open'] = ('path', 'create', 'lock_wait', 'lock', ),
|
||||||
compatMap['open'] = ('path', 'create', 'lock_wait', 'lock', )
|
# try again with corrected version and compatMap
|
||||||
self.id = self.call('open', {'path': self.location.path, 'create': create, 'lock_wait': lock_wait,
|
do_open()
|
||||||
'lock': lock, 'exclusive': exclusive, 'append_only': append_only})
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.close()
|
self.close()
|
||||||
raise
|
raise
|
||||||
|
@ -630,6 +633,11 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
|
||||||
raise
|
raise
|
||||||
self.ignore_responses |= set(waiting_for)
|
self.ignore_responses |= set(waiting_for)
|
||||||
|
|
||||||
|
@api(since=parse_version('1.0.0'),
|
||||||
|
append_only={'since': parse_version('1.0.7'), 'previously': False})
|
||||||
|
def open(self, path, create=False, lock_wait=None, lock=True, exclusive=False, append_only=False):
|
||||||
|
"""actual remoting is done via self.call in the @api decorator"""
|
||||||
|
|
||||||
@api(since=parse_version('1.0.0'))
|
@api(since=parse_version('1.0.0'))
|
||||||
def check(self, repair=False, save_space=False):
|
def check(self, repair=False, save_space=False):
|
||||||
"""actual remoting is done via self.call in the @api decorator"""
|
"""actual remoting is done via self.call in the @api decorator"""
|
||||||
|
|
Loading…
Reference in New Issue