Fix broken repository detection in the "rcreate" action with Borg 1.4 (#820).

This commit is contained in:
Dan Helfman 2024-01-24 15:45:51 -08:00
parent 009062128d
commit ad1d104d65
3 changed files with 5 additions and 3 deletions

2
NEWS
View file

@ -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

View file

@ -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')

View file

@ -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], [])
)