Browse Source

Add Btrfs "/" subvolume fix to NEWS.

Dan Helfman 3 months ago
parent
commit
056dfc6d33
3 changed files with 6 additions and 2 deletions
  1. 2 0
      NEWS
  2. 3 1
      borgmatic/hooks/data_source/btrfs.py
  3. 1 1
      tests/unit/hooks/data_source/test_btrfs.py

+ 2 - 0
NEWS

@@ -3,6 +3,8 @@
    databases are enabled.
  * Add credential loading from file, KeePassXC, and Docker/Podman secrets. See the documentation for
    more information: https://torsion.org/borgmatic/docs/how-to/provide-your-passwords/
+ * Fix another error in the Btrfs hook when a subvolume mounted at "/" is configured in borgmatic's
+   source directories.
 
 1.9.10
  * #966: Add a "{credential ...}" syntax for loading systemd credentials into borgmatic

+ 3 - 1
borgmatic/hooks/data_source/btrfs.py

@@ -299,8 +299,10 @@ def remove_data_source_dumps(hook_config, config, borgmatic_runtime_directory, d
                 logger.debug(error)
                 return
 
-            # Remove snapshot parent directory if it still exists (might not exist if snapshot was for '/')
+            # Remove the snapshot parent directory if it still exists. (It might not exist if the
+            # snapshot was for "/".)
             snapshot_parent_dir = snapshot_path.rsplit(subvolume.path, 1)[0]
+
             if os.path.isdir(snapshot_parent_dir):
                 shutil.rmtree(snapshot_parent_dir)
 

+ 1 - 1
tests/unit/hooks/data_source/test_btrfs.py

@@ -860,7 +860,7 @@ def test_remove_data_source_dumps_with_delete_snapshot_called_process_error_bail
     )
 
 
-def test_remove_data_source_dumps_with_root_subvolume():
+def test_remove_data_source_dumps_with_root_subvolume_skips_duplicate_removal():
     config = {'btrfs': {}}
     flexmock(module).should_receive('get_subvolumes').and_return(
         (module.Subvolume('/', contained_patterns=(Pattern('/etc'),)),)