diff --git a/NEWS b/NEWS index 50391a87..8f3ffc2c 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ * #697, #712: Extract borgmatic configuration from backup via "bootstrap" action—even when borgmatic has no configuration yet! * #669: Add sample systemd user service for running borgmatic as a non-root user. + * #711, #713: Fix an error when "data" check time files are accessed without getting upgraded + first. 1.7.14 * #484: Add a new verbosity level (-2) to disable output entirely (for console, syslog, log file, diff --git a/borgmatic/borg/check.py b/borgmatic/borg/check.py index 0c417aca..0e54a2cd 100644 --- a/borgmatic/borg/check.py +++ b/borgmatic/borg/check.py @@ -342,7 +342,7 @@ def upgrade_check_times(location_config, borg_repository_id): temporary_path = f'{old_path}.temp' if not os.path.isfile(old_path) and not os.path.isfile(temporary_path): - return + continue logger.debug(f'Upgrading archives check time from {old_path} to {new_path}') diff --git a/tests/unit/borg/test_check.py b/tests/unit/borg/test_check.py index a1044ba4..79201166 100644 --- a/tests/unit/borg/test_check.py +++ b/tests/unit/borg/test_check.py @@ -544,6 +544,34 @@ def test_upgrade_check_times_renames_old_check_paths_to_all(): module.upgrade_check_times(flexmock(), flexmock()) +def test_upgrade_check_times_renames_data_check_paths_when_archives_paths_are_already_upgraded(): + base_path = '~/.borgmatic/checks/1234' + flexmock(module).should_receive('make_check_time_path').with_args( + object, object, 'archives', 'all' + ).and_return(f'{base_path}/archives/all') + flexmock(module).should_receive('make_check_time_path').with_args( + object, object, 'data', 'all' + ).and_return(f'{base_path}/data/all') + flexmock(module.os.path).should_receive('isfile').with_args(f'{base_path}/archives').and_return( + False + ) + flexmock(module.os.path).should_receive('isfile').with_args( + f'{base_path}/archives.temp' + ).and_return(False) + flexmock(module.os.path).should_receive('isfile').with_args(f'{base_path}/data').and_return( + True + ) + flexmock(module.os).should_receive('rename').with_args( + f'{base_path}/data', f'{base_path}/data.temp' + ).once() + flexmock(module.os).should_receive('mkdir').with_args(f'{base_path}/data').once() + flexmock(module.os).should_receive('rename').with_args( + f'{base_path}/data.temp', f'{base_path}/data/all' + ).once() + + module.upgrade_check_times(flexmock(), flexmock()) + + def test_upgrade_check_times_skips_missing_check_paths(): flexmock(module).should_receive('make_check_time_path').and_return( '~/.borgmatic/checks/1234/archives/all'