|
@@ -114,7 +114,7 @@ class RepositoryServer: # pragma: no cover
|
|
def negotiate(self, versions):
|
|
def negotiate(self, versions):
|
|
return RPC_PROTOCOL_VERSION
|
|
return RPC_PROTOCOL_VERSION
|
|
|
|
|
|
- def open(self, path, create=False, lock_wait=None, lock=True, append_only=False):
|
|
|
|
|
|
+ def open(self, path, create=False, lock_wait=None, lock=True, exclusive=False, append_only=False):
|
|
path = os.fsdecode(path)
|
|
path = os.fsdecode(path)
|
|
if path.startswith('/~'):
|
|
if path.startswith('/~'):
|
|
path = path[1:]
|
|
path = path[1:]
|
|
@@ -125,7 +125,9 @@ class RepositoryServer: # pragma: no cover
|
|
break
|
|
break
|
|
else:
|
|
else:
|
|
raise PathNotAllowed(path)
|
|
raise PathNotAllowed(path)
|
|
- self.repository = Repository(path, create, lock_wait=lock_wait, lock=lock, append_only=self.append_only or append_only)
|
|
|
|
|
|
+ self.repository = Repository(path, create, lock_wait=lock_wait, lock=lock,
|
|
|
|
+ append_only=self.append_only or append_only,
|
|
|
|
+ exclusive=exclusive)
|
|
self.repository.__enter__() # clean exit handled by serve() method
|
|
self.repository.__enter__() # clean exit handled by serve() method
|
|
return self.repository.id
|
|
return self.repository.id
|
|
|
|
|
|
@@ -141,7 +143,7 @@ class RemoteRepository:
|
|
class NoAppendOnlyOnServer(Error):
|
|
class NoAppendOnlyOnServer(Error):
|
|
"""Server does not support --append-only."""
|
|
"""Server does not support --append-only."""
|
|
|
|
|
|
- def __init__(self, location, create=False, lock_wait=None, lock=True, append_only=False, args=None):
|
|
|
|
|
|
+ def __init__(self, location, create=False, exclusive=False, lock_wait=None, lock=True, append_only=False, args=None):
|
|
self.location = self._location = location
|
|
self.location = self._location = location
|
|
self.preload_ids = []
|
|
self.preload_ids = []
|
|
self.msgid = 0
|
|
self.msgid = 0
|
|
@@ -178,16 +180,13 @@ class RemoteRepository:
|
|
raise ConnectionClosedWithHint('Is borg working on the server?') from None
|
|
raise ConnectionClosedWithHint('Is borg working on the server?') from None
|
|
if version != RPC_PROTOCOL_VERSION:
|
|
if version != RPC_PROTOCOL_VERSION:
|
|
raise Exception('Server insisted on using unsupported protocol version %d' % version)
|
|
raise Exception('Server insisted on using unsupported protocol version %d' % version)
|
|
- # Because of protocol versions, only send append_only if necessary
|
|
|
|
- if append_only:
|
|
|
|
- try:
|
|
|
|
- self.id = self.call('open', self.location.path, create, lock_wait, lock, append_only)
|
|
|
|
- except self.RPCError as err:
|
|
|
|
- if err.remote_type == 'TypeError':
|
|
|
|
- raise self.NoAppendOnlyOnServer() from err
|
|
|
|
- else:
|
|
|
|
- raise
|
|
|
|
- else:
|
|
|
|
|
|
+ try:
|
|
|
|
+ self.id = self.call('open', self.location.path, create, lock_wait, lock, exclusive, append_only)
|
|
|
|
+ except self.RPCError as err:
|
|
|
|
+ if err.remote_type != 'TypeError':
|
|
|
|
+ raise
|
|
|
|
+ if append_only:
|
|
|
|
+ raise self.NoAppendOnlyOnServer()
|
|
self.id = self.call('open', self.location.path, create, lock_wait, lock)
|
|
self.id = self.call('open', self.location.path, create, lock_wait, lock)
|
|
except Exception:
|
|
except Exception:
|
|
self.close()
|
|
self.close()
|