From e3d40125cbb30a1cfa9952537a8e97d1a1ffce62 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 18 Jan 2025 09:54:30 -0800 Subject: [PATCH] Fix for a "spot" check error when a filename in the most recent archive contains a newline (#968). --- NEWS | 3 ++- borgmatic/actions/check.py | 2 +- borgmatic/borg/list.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f062e4d3..efd764af 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ 1.9.7 - * #970: Fix for an error when a blank line occurs in the configured patterns or excludes. + * #968: Fix for a "spot" check error when a filename in the most recent archive contains a newline. + * #970: Fix for an error when there's a blank line in the configured patterns or excludes. 1.9.6 * #959: Fix an error in the Btrfs hook when a subvolume mounted at "/" is configured in borgmatic's diff --git a/borgmatic/actions/check.py b/borgmatic/actions/check.py index 5e7b401d..8c9575e4 100644 --- a/borgmatic/actions/check.py +++ b/borgmatic/actions/check.py @@ -401,7 +401,7 @@ def collect_spot_check_source_paths( paths = tuple( path_line.split(' ', 1)[1] - for path_line in paths_output.split('\n') + for path_line in paths_output.splitlines() if path_line and path_line.startswith('- ') or path_line.startswith('+ ') ) diff --git a/borgmatic/borg/list.py b/borgmatic/borg/list.py index 55d4a592..d995f262 100644 --- a/borgmatic/borg/list.py +++ b/borgmatic/borg/list.py @@ -120,7 +120,7 @@ def capture_archive_listing( paths=[path for path in list_paths] if list_paths else None, find_paths=None, json=None, - format=path_format or '{path}{NL}', # noqa: FS003 + format=path_format or '{path}{NUL}', # noqa: FS003 ), global_arguments, local_path, @@ -132,7 +132,7 @@ def capture_archive_listing( borg_exit_codes=config.get('borg_exit_codes'), ) .strip('\n') - .split('\n') + .split('\0') ) @@ -230,7 +230,7 @@ def list_archive( borg_exit_codes=borg_exit_codes, ) .strip('\n') - .split('\n') + .splitlines() ) else: archive_lines = (list_arguments.archive,)