From da8278b566f6fdafbcf58d655b86401582444a62 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Thu, 21 Nov 2024 08:36:15 -0800 Subject: [PATCH] Use os.path.normpath() instead of custom list comprehension (#261). --- borgmatic/hooks/zfs.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/borgmatic/hooks/zfs.py b/borgmatic/hooks/zfs.py index 1e7cf822..bfc52b3a 100644 --- a/borgmatic/hooks/zfs.py +++ b/borgmatic/hooks/zfs.py @@ -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}')