mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
BackupError->BackupWarning, BackupOSError->BackupOSWarning
This commit is contained in:
parent
900a1674df
commit
e8fa4986cc
4 changed files with 28 additions and 17 deletions
|
@ -29,7 +29,7 @@
|
|||
from ..helpers import sig_int, ignore_sigint
|
||||
from ..helpers import iter_separated
|
||||
from ..helpers import MakePathSafeAction
|
||||
from ..helpers import Error, CommandError, BackupExcWarning, FileChangedWarning
|
||||
from ..helpers import Error, CommandError, BackupWarning, BackupOSWarning, FileChangedWarning
|
||||
from ..manifest import Manifest
|
||||
from ..patterns import PatternMatcher
|
||||
from ..platform import is_win32
|
||||
|
@ -121,8 +121,11 @@ def create_inner(archive, cache, fso):
|
|||
read_special=args.read_special,
|
||||
dry_run=dry_run,
|
||||
)
|
||||
except (BackupOSError, BackupError) as e:
|
||||
self.print_warning_instance(BackupExcWarning(path, e))
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupOSWarning(path, e))
|
||||
status = "E"
|
||||
except BackupError as e:
|
||||
self.print_warning_instance(BackupWarning(path, e))
|
||||
status = "E"
|
||||
if status == "C":
|
||||
self.print_warning_instance(FileChangedWarning(path))
|
||||
|
@ -149,7 +152,7 @@ def create_inner(archive, cache, fso):
|
|||
path=path, cache=cache, fd=sys.stdin.buffer, mode=mode, user=user, group=group
|
||||
)
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupExcWarning(path, e))
|
||||
self.print_warning_instance(BackupOSWarning(path, e))
|
||||
status = "E"
|
||||
else:
|
||||
status = "+" # included
|
||||
|
@ -180,9 +183,9 @@ def create_inner(archive, cache, fso):
|
|||
# if we get back here, we've finished recursing into <path>,
|
||||
# we do not ever want to get back in there (even if path is given twice as recursion root)
|
||||
skip_inodes.add((st.st_ino, st.st_dev))
|
||||
except (BackupOSError, BackupError) as e:
|
||||
except BackupOSError as e:
|
||||
# this comes from os.stat, self._rec_walk has own exception handler
|
||||
self.print_warning_instance(BackupExcWarning(path, e))
|
||||
self.print_warning_instance(BackupOSWarning(path, e))
|
||||
continue
|
||||
if not dry_run:
|
||||
if args.progress:
|
||||
|
@ -521,8 +524,11 @@ def _rec_walk(
|
|||
dry_run=dry_run,
|
||||
)
|
||||
|
||||
except (BackupOSError, BackupError) as e:
|
||||
self.print_warning_instance(BackupExcWarning(path, e))
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupOSWarning(path, e))
|
||||
status = "E"
|
||||
except BackupError as e:
|
||||
self.print_warning_instance(BackupWarning(path, e))
|
||||
status = "E"
|
||||
if status == "C":
|
||||
self.print_warning_instance(FileChangedWarning(path))
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
from ..helpers import remove_surrogates
|
||||
from ..helpers import HardLinkManager
|
||||
from ..helpers import ProgressIndicatorPercent
|
||||
from ..helpers import BackupExcWarning, IncludePatternNeverMatchedWarning
|
||||
from ..helpers import BackupWarning, BackupOSWarning, IncludePatternNeverMatchedWarning
|
||||
from ..manifest import Manifest
|
||||
|
||||
from ..logger import create_logger
|
||||
|
@ -66,7 +66,7 @@ def do_extract(self, args, repository, manifest, archive):
|
|||
try:
|
||||
archive.extract_item(dir_item, stdout=stdout)
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupExcWarning(remove_surrogates(dir_item.path), e))
|
||||
self.print_warning_instance(BackupOSWarning(remove_surrogates(dir_item.path), e))
|
||||
if output_list:
|
||||
logging.getLogger("borg.output.list").info(remove_surrogates(item.path))
|
||||
try:
|
||||
|
@ -80,9 +80,10 @@ def do_extract(self, args, repository, manifest, archive):
|
|||
archive.extract_item(
|
||||
item, stdout=stdout, sparse=sparse, hlm=hlm, pi=pi, continue_extraction=continue_extraction
|
||||
)
|
||||
except (BackupOSError, BackupError) as e:
|
||||
self.print_warning_instance(BackupExcWarning(remove_surrogates(orig_path), e))
|
||||
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupOSWarning(remove_surrogates(orig_path), e))
|
||||
except BackupError as e:
|
||||
self.print_warning_instance(BackupWarning(remove_surrogates(orig_path), e))
|
||||
if pi:
|
||||
pi.finish()
|
||||
|
||||
|
@ -96,7 +97,7 @@ def do_extract(self, args, repository, manifest, archive):
|
|||
try:
|
||||
archive.extract_item(dir_item, stdout=stdout)
|
||||
except BackupOSError as e:
|
||||
self.print_warning_instance(BackupExcWarning(remove_surrogates(dir_item.path), e))
|
||||
self.print_warning_instance(BackupOSWarning(remove_surrogates(dir_item.path), e))
|
||||
for pattern in matcher.get_unmatched_include_patterns():
|
||||
self.print_warning_instance(IncludePatternNeverMatchedWarning(pattern))
|
||||
if pi:
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
from .datastruct import StableDict, Buffer, EfficientCollectionQueue
|
||||
from .errors import Error, ErrorWithTraceback, IntegrityError, DecompressionError, CancelledByUser, CommandError
|
||||
from .errors import RTError, modern_ec
|
||||
from .errors import BorgWarning, FileChangedWarning, BackupExcWarning, IncludePatternNeverMatchedWarning
|
||||
from .errors import BorgWarning, FileChangedWarning, BackupWarning, BackupOSWarning, IncludePatternNeverMatchedWarning
|
||||
from .errors import BackupError, BackupOSError, BackupRaceConditionError
|
||||
from .fs import ensure_dir, join_base_dir, get_socket_filename
|
||||
from .fs import get_security_dir, get_keys_dir, get_base_dir, get_cache_dir, get_config_dir, get_runtime_dir
|
||||
|
|
|
@ -108,12 +108,16 @@ class IncludePatternNeverMatchedWarning(BorgWarning):
|
|||
exit_mcode = 101
|
||||
|
||||
|
||||
class BackupExcWarning(BorgWarning):
|
||||
class BackupWarning(BorgWarning):
|
||||
"""{}: {}"""
|
||||
|
||||
exit_mcode = 102
|
||||
|
||||
# TODO: override exit_code and compute the exit code based on the wrapped exception.
|
||||
|
||||
class BackupOSWarning(BorgWarning):
|
||||
"""{}: {}"""
|
||||
|
||||
exit_mcode = 104
|
||||
|
||||
|
||||
class BackupError(Exception):
|
||||
|
|
Loading…
Reference in a new issue