From 7b4a986f13b63407defb9e918c75f416b7247013 Mon Sep 17 00:00:00 2001 From: Edwin Eefting Date: Sun, 19 Dec 2021 18:16:54 +0100 Subject: [PATCH] fix #103 --- tests/test_regressions.py | 47 ++++++++++++++++++++++++++++++++++++ zfs_autobackup/ZfsDataset.py | 3 ++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 6f11dfd..4592599 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -56,3 +56,50 @@ test_target1/test_source2/fs2/sub@test-20101111000000 test_target1/test_source2/fs2/sub@test-20101111000001 test_target1/test_source2/fs2/sub@test-20101111000002 """) + + + def test_excludepaths(self): + """Test issue #103""" + + shelltest("zfs create test_target1/target_shouldnotbeexcluded") + shelltest("zfs set autobackup:test=true test_target1/target_shouldnotbeexcluded") + shelltest("zfs create test_target1/target") + + with patch('time.strftime', return_value="test-20101111000000"): + self.assertFalse(ZfsAutobackup( + "test test_target1/target --no-progress --verbose --allow-empty".split( + " ")).run()) + + + r = shelltest("zfs list -H -o name -r -t all " + TEST_POOLS) + self.assertMultiLineEqual(r, """ +test_source1 +test_source1/fs1 +test_source1/fs1@test-20101111000000 +test_source1/fs1/sub +test_source1/fs1/sub@test-20101111000000 +test_source2 +test_source2/fs2 +test_source2/fs2/sub +test_source2/fs2/sub@test-20101111000000 +test_source2/fs3 +test_source2/fs3/sub +test_target1 +test_target1/target +test_target1/target/test_source1 +test_target1/target/test_source1/fs1 +test_target1/target/test_source1/fs1@test-20101111000000 +test_target1/target/test_source1/fs1/sub +test_target1/target/test_source1/fs1/sub@test-20101111000000 +test_target1/target/test_source2 +test_target1/target/test_source2/fs2 +test_target1/target/test_source2/fs2/sub +test_target1/target/test_source2/fs2/sub@test-20101111000000 +test_target1/target/test_target1 +test_target1/target/test_target1/target_shouldnotbeexcluded +test_target1/target/test_target1/target_shouldnotbeexcluded@test-20101111000000 +test_target1/target_shouldnotbeexcluded +test_target1/target_shouldnotbeexcluded@test-20101111000000 +""") + + diff --git a/zfs_autobackup/ZfsDataset.py b/zfs_autobackup/ZfsDataset.py index 7b86ad2..da56b54 100644 --- a/zfs_autobackup/ZfsDataset.py +++ b/zfs_autobackup/ZfsDataset.py @@ -158,7 +158,8 @@ class ZfsDataset: # our path starts with one of the excluded paths? for exclude_path in exclude_paths: - if self.name.startswith(exclude_path): + # if self.name.startswith(exclude_path): + if (self.name + "/").startswith(exclude_path + "/"): # too noisy for verbose self.debug("Excluded (path in exclude list)") return False