mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-08-01 22:23:01 +02:00
hotfix
This commit is contained in:
@@ -29,6 +29,10 @@ def recreate_archive(
|
||||
'''
|
||||
lock_wait = config.get('lock_wait', None)
|
||||
|
||||
if archive is None:
|
||||
logger.error('Please provide a valid archive name.')
|
||||
return
|
||||
|
||||
repo_archive_arg = make_repository_archive_flags(repository, archive, local_borg_version)
|
||||
exclude_flags = make_exclude_flags(config)
|
||||
|
||||
@@ -40,9 +44,13 @@ def recreate_archive(
|
||||
recreate_cmd = (
|
||||
(local_path, 'recreate')
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ (('--path', recreate_arguments.path) if recreate_arguments.path else ())
|
||||
+ (
|
||||
('--path', recreate_arguments.path)
|
||||
if hasattr(recreate_arguments, 'path') and recreate_arguments.path
|
||||
else ()
|
||||
)
|
||||
+ (('--log-json',) if global_arguments.log_json else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait is not None else ())
|
||||
+ (('--info',) if logger.getEffectiveLevel() == logging.INFO else ())
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--patterns-from', patterns_file.name) if patterns_file else ())
|
||||
@@ -52,7 +60,7 @@ def recreate_archive(
|
||||
'--filter',
|
||||
make_list_filter_flags(local_borg_version, global_arguments.dry_run),
|
||||
)
|
||||
if recreate_arguments.list
|
||||
if hasattr(recreate_arguments, 'list') and recreate_arguments.list
|
||||
else ()
|
||||
)
|
||||
+ exclude_flags
|
||||
|
||||
@@ -64,6 +64,24 @@ def test_recreate_calls_borg_with_required_flags():
|
||||
)
|
||||
|
||||
|
||||
def test_recreate_calls_borg_without_archive():
|
||||
logger_mock = flexmock(module.logger)
|
||||
logger_mock.should_receive('error').with_args('Please provide a valid archive name.').once()
|
||||
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').never()
|
||||
|
||||
module.recreate_archive(
|
||||
repository='repo',
|
||||
archive=None,
|
||||
config={},
|
||||
local_borg_version='1.2.3',
|
||||
recreate_arguments=flexmock(path=None, list=None),
|
||||
global_arguments=flexmock(dry_run=False, log_json=False),
|
||||
local_path='borg',
|
||||
patterns=None,
|
||||
)
|
||||
|
||||
|
||||
def test_recreate_with_remote_path():
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('repo::archive',)
|
||||
|
||||
Reference in New Issue
Block a user