Browse Source

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

Dan Helfman 9 months ago
parent
commit
da8278b566
1 changed files with 2 additions and 13 deletions
  1. 2 13
      borgmatic/hooks/zfs.py

+ 2 - 13
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}')