mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-04 06:21:46 +00:00
remote repos: remove support for borg < 1.1.0 (exceptions)
exception infos: ancient borg gave only limited infos about exceptions, but recent ones give more.
This commit is contained in:
parent
591d8efac4
commit
51177b9f06
1 changed files with 9 additions and 32 deletions
|
@ -421,15 +421,11 @@ class RemoteRepository:
|
||||||
|
|
||||||
class RPCError(Exception):
|
class RPCError(Exception):
|
||||||
def __init__(self, unpacked):
|
def __init__(self, unpacked):
|
||||||
# for borg < 1.1: unpacked only has 'exception_class' as key
|
# unpacked has keys: 'exception_args', 'exception_full', 'exception_short', 'sysinfo'
|
||||||
# for borg 1.1+: unpacked has keys: 'exception_args', 'exception_full', 'exception_short', 'sysinfo'
|
|
||||||
self.unpacked = unpacked
|
self.unpacked = unpacked
|
||||||
|
|
||||||
def get_message(self):
|
def get_message(self):
|
||||||
if "exception_short" in self.unpacked:
|
return "\n".join(self.unpacked["exception_short"])
|
||||||
return "\n".join(self.unpacked["exception_short"])
|
|
||||||
else:
|
|
||||||
return self.exception_class
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def traceback(self):
|
def traceback(self):
|
||||||
|
@ -441,17 +437,11 @@ def exception_class(self):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def exception_full(self):
|
def exception_full(self):
|
||||||
if "exception_full" in self.unpacked:
|
return "\n".join(self.unpacked["exception_full"])
|
||||||
return "\n".join(self.unpacked["exception_full"])
|
|
||||||
else:
|
|
||||||
return self.get_message() + "\nRemote Exception (see remote log for the traceback)"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sysinfo(self):
|
def sysinfo(self):
|
||||||
if "sysinfo" in self.unpacked:
|
return self.unpacked.get("sysinfo", "")
|
||||||
return self.unpacked["sysinfo"]
|
|
||||||
else:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
class RPCServerOutdated(Error):
|
class RPCServerOutdated(Error):
|
||||||
"""Borg server is too old for {}. Required version {}"""
|
"""Borg server is too old for {}. Required version {}"""
|
||||||
|
@ -661,8 +651,7 @@ def pop_preload_msgid(chunkid):
|
||||||
|
|
||||||
def handle_error(unpacked):
|
def handle_error(unpacked):
|
||||||
error = unpacked["exception_class"]
|
error = unpacked["exception_class"]
|
||||||
old_server = "exception_args" not in unpacked
|
args = unpacked["exception_args"]
|
||||||
args = unpacked.get("exception_args")
|
|
||||||
|
|
||||||
if error == "DoesNotExist":
|
if error == "DoesNotExist":
|
||||||
raise Repository.DoesNotExist(self.location.processed)
|
raise Repository.DoesNotExist(self.location.processed)
|
||||||
|
@ -671,27 +660,15 @@ def handle_error(unpacked):
|
||||||
elif error == "CheckNeeded":
|
elif error == "CheckNeeded":
|
||||||
raise Repository.CheckNeeded(self.location.processed)
|
raise Repository.CheckNeeded(self.location.processed)
|
||||||
elif error == "IntegrityError":
|
elif error == "IntegrityError":
|
||||||
if old_server:
|
raise IntegrityError(args[0])
|
||||||
raise IntegrityError("(not available)")
|
|
||||||
else:
|
|
||||||
raise IntegrityError(args[0])
|
|
||||||
elif error == "PathNotAllowed":
|
elif error == "PathNotAllowed":
|
||||||
if old_server:
|
raise PathNotAllowed(args[0])
|
||||||
raise PathNotAllowed("(unknown)")
|
|
||||||
else:
|
|
||||||
raise PathNotAllowed(args[0])
|
|
||||||
elif error == "ParentPathDoesNotExist":
|
elif error == "ParentPathDoesNotExist":
|
||||||
raise Repository.ParentPathDoesNotExist(args[0])
|
raise Repository.ParentPathDoesNotExist(args[0])
|
||||||
elif error == "ObjectNotFound":
|
elif error == "ObjectNotFound":
|
||||||
if old_server:
|
raise Repository.ObjectNotFound(args[0], self.location.processed)
|
||||||
raise Repository.ObjectNotFound("(not available)", self.location.processed)
|
|
||||||
else:
|
|
||||||
raise Repository.ObjectNotFound(args[0], self.location.processed)
|
|
||||||
elif error == "InvalidRPCMethod":
|
elif error == "InvalidRPCMethod":
|
||||||
if old_server:
|
raise InvalidRPCMethod(args[0])
|
||||||
raise InvalidRPCMethod("(not available)")
|
|
||||||
else:
|
|
||||||
raise InvalidRPCMethod(args[0])
|
|
||||||
else:
|
else:
|
||||||
raise self.RPCError(unpacked)
|
raise self.RPCError(unpacked)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue