Use os.path.normpath() instead of custom list comprehension (#261).

This commit is contained in:
Dan Helfman 2024-11-21 08:36:15 -08:00
parent 2af3522902
commit da8278b566

View File

@ -92,13 +92,7 @@ def dump_data_sources(
# Mount the snapshot into a particular named temporary directory so that the snapshot ends
# up in the Borg archive at the "original" dataset mount point path.
snapshot_path = os.path.join(
# TODO: Maybe factor out into normalize_runtime_directory() utility function.
'/',
*(
subdirectory
for subdirectory in borgmatic_runtime_directory.split(os.path.sep)
if subdirectory != '.'
),
os.path.normpath(borgmatic_runtime_directory),
'zfs_snapshots',
'.',
mount_point.lstrip(os.path.sep),
@ -154,12 +148,7 @@ def remove_data_source_dumps(hook_config, config, log_prefix, borgmatic_runtime_
# FIXME: This doesn't necessarily find snapshot mounts from previous borgmatic runs, because
# borgmatic_runtime_directory could be in a tempfile-created directory that has a random name.
snapshots_directory = os.path.join(
'/',
*(
subdirectory
for subdirectory in borgmatic_runtime_directory.split(os.path.sep)
if subdirectory != '.'
),
os.path.normpath(borgmatic_runtime_directory),
'zfs_snapshots',
)
logger.debug(f'{log_prefix}: Looking for snapshots in {snapshots_directory}')