From ad1d104d65f3ba3f092d65bb6dc48f7c65791859 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 24 Jan 2024 15:45:51 -0800 Subject: [PATCH] Fix broken repository detection in the "rcreate" action with Borg 1.4 (#820). --- NEWS | 2 ++ borgmatic/borg/rcreate.py | 4 ++-- tests/unit/borg/test_rcreate.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 92661103..d98c6236 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ 1.8.8.dev0 * #818: Allow the "--repository" flag to match across multiple configuration files. + * #820: Fix broken repository detection in the "rcreate" action with Borg 1.4. The issue did not + occur with other versions of Borg. 1.8.7 * #736: Store included configuration files within each backup archive in support of the "config diff --git a/borgmatic/borg/rcreate.py b/borgmatic/borg/rcreate.py index 935b183b..0acd6b30 100644 --- a/borgmatic/borg/rcreate.py +++ b/borgmatic/borg/rcreate.py @@ -8,7 +8,7 @@ from borgmatic.execute import DO_NOT_CAPTURE, execute_command logger = logging.getLogger(__name__) -RINFO_REPOSITORY_NOT_FOUND_EXIT_CODE = 2 +RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES = {2, 13} def create_repository( @@ -45,7 +45,7 @@ def create_repository( logger.info(f'{repository_path}: Repository already exists. Skipping creation.') return except subprocess.CalledProcessError as error: - if error.returncode != RINFO_REPOSITORY_NOT_FOUND_EXIT_CODE: + if error.returncode not in RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES: raise lock_wait = config.get('lock_wait') diff --git a/tests/unit/borg/test_rcreate.py b/tests/unit/borg/test_rcreate.py index 8927f291..56e83309 100644 --- a/tests/unit/borg/test_rcreate.py +++ b/tests/unit/borg/test_rcreate.py @@ -18,7 +18,7 @@ def insert_rinfo_command_found_mock(): def insert_rinfo_command_not_found_mock(): flexmock(module.rinfo).should_receive('display_repository_info').and_raise( - subprocess.CalledProcessError(module.RINFO_REPOSITORY_NOT_FOUND_EXIT_CODE, []) + subprocess.CalledProcessError(sorted(module.RINFO_REPOSITORY_NOT_FOUND_EXIT_CODES)[0], []) )