mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-09 21:57:24 +00:00
upgrade: auto-use ignore_invalid_archive_tam
This commit is contained in:
parent
ed80bf2c37
commit
69a4ea7682
2 changed files with 53 additions and 39 deletions
|
@ -76,6 +76,7 @@ try:
|
|||
from .helpers import sig_int, ignore_sigint
|
||||
from .helpers import iter_separated
|
||||
from .helpers import get_tar_filter
|
||||
from .helpers import ignore_invalid_archive_tam
|
||||
from .helpers.parseformat import BorgJsonEncoder, safe_decode
|
||||
from .nanorst import rst_to_terminal
|
||||
from .patterns import ArgparsePatternAction, ArgparseExcludeFileAction, ArgparsePatternFileAction, parse_exclude_pattern
|
||||
|
@ -1613,6 +1614,7 @@ class Archiver:
|
|||
def do_upgrade(self, args, repository, manifest=None, key=None):
|
||||
"""upgrade a repository from a previous version"""
|
||||
if args.archives_tam or args.check_archives_tam:
|
||||
with ignore_invalid_archive_tam():
|
||||
archive_tam_issues = 0
|
||||
read_only = args.check_archives_tam
|
||||
manifest, key = Manifest.load(repository, (Manifest.Operation.CHECK,), force_tam_not_required=args.force)
|
||||
|
|
|
@ -5,6 +5,7 @@ that did not fit better elsewhere.
|
|||
Code used to be in borg/helpers.py but was split into the modules in this
|
||||
package, which are imported into here for compatibility.
|
||||
"""
|
||||
from contextlib import contextmanager
|
||||
|
||||
from .checks import * # NOQA
|
||||
from .datastruct import * # NOQA
|
||||
|
@ -27,6 +28,17 @@ from . import msgpack
|
|||
workarounds = tuple(os.environ.get('BORG_WORKAROUNDS', '').split(','))
|
||||
|
||||
|
||||
@contextmanager
|
||||
def ignore_invalid_archive_tam():
|
||||
global workarounds
|
||||
saved = workarounds
|
||||
if 'ignore_invalid_archive_tam' not in workarounds:
|
||||
# we really need this workaround here or borg will likely raise an exception.
|
||||
workarounds += ('ignore_invalid_archive_tam',)
|
||||
yield
|
||||
workarounds = saved
|
||||
|
||||
|
||||
# element data type for warnings_list:
|
||||
warning_info = namedtuple("warning_info", "wc,msg,args,wt")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue