mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-30 21:33:00 +02:00
Run borg with --progress during extract dry run if passed to borgmatic check.
This commit is contained in:
@@ -49,9 +49,10 @@ def extract_last_archive_dry_run(
|
||||
full_extract_command = (
|
||||
(local_path, 'extract', '--dry-run')
|
||||
+ (('--remote-path', remote_path) if remote_path else ())
|
||||
+ ('--log-json',)
|
||||
+ (('--log-json',) if not config.get('progress') else ())
|
||||
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||
+ verbosity_flags
|
||||
+ (('--progress',) if config.get('progress') else ())
|
||||
+ list_flag
|
||||
+ (tuple(shlex.split(extra_borg_options)) if extra_borg_options else ())
|
||||
+ flags.make_repository_archive_flags(
|
||||
@@ -61,13 +62,23 @@ def extract_last_archive_dry_run(
|
||||
)
|
||||
)
|
||||
|
||||
execute_command(
|
||||
full_extract_command,
|
||||
environment=environment.make_environment(config),
|
||||
working_directory=borgmatic.config.paths.get_working_directory(config),
|
||||
borg_local_path=local_path,
|
||||
borg_exit_codes=config.get('borg_exit_codes'),
|
||||
)
|
||||
if config.get('progress'):
|
||||
execute_command(
|
||||
full_extract_command,
|
||||
output_file=DO_NOT_CAPTURE,
|
||||
environment=environment.make_environment(config),
|
||||
working_directory=borgmatic.config.paths.get_working_directory(config),
|
||||
borg_local_path=local_path,
|
||||
borg_exit_codes=config.get('borg_exit_codes'),
|
||||
)
|
||||
else:
|
||||
execute_command(
|
||||
full_extract_command,
|
||||
environment=environment.make_environment(config),
|
||||
working_directory=borgmatic.config.paths.get_working_directory(config),
|
||||
borg_local_path=local_path,
|
||||
borg_exit_codes=config.get('borg_exit_codes'),
|
||||
)
|
||||
|
||||
|
||||
def extract_archive(
|
||||
|
||||
@@ -95,6 +95,30 @@ def test_extract_last_archive_dry_run_with_log_debug_calls_borg_with_debug_param
|
||||
)
|
||||
|
||||
|
||||
def test_extract_last_archive_dry_run_calls_borg_with_progress_flag():
|
||||
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
|
||||
flexmock(module.environment).should_receive('make_environment')
|
||||
flexmock(module).should_receive('execute_command').with_args(
|
||||
('borg', 'extract', '--dry-run', '--progress', 'repo::archive'),
|
||||
output_file=module.DO_NOT_CAPTURE,
|
||||
environment=None,
|
||||
working_directory=None,
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
|
||||
('repo::archive',),
|
||||
)
|
||||
|
||||
module.extract_last_archive_dry_run(
|
||||
config={'progress': True},
|
||||
local_borg_version='1.2.3',
|
||||
global_arguments=flexmock(),
|
||||
repository_path='repo',
|
||||
lock_wait=None,
|
||||
)
|
||||
|
||||
|
||||
def test_extract_last_archive_dry_run_calls_borg_via_local_path():
|
||||
flexmock(module.repo_list).should_receive('resolve_archive_name').and_return('archive')
|
||||
insert_execute_command_mock(('borg1', 'extract', '--dry-run', '--log-json', 'repo::archive'))
|
||||
|
||||
Reference in New Issue
Block a user