From c38eef4fb3ddc1e0f2808bf118a5f7dc6fa1a0a0 Mon Sep 17 00:00:00 2001 From: bescoto Date: Tue, 10 Jan 2006 06:15:42 +0000 Subject: Fix for Toni Price's empty dir --include **XXX selection bug git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/branches/r1-0@739 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 4 ++++ rdiff-backup/rdiff_backup/selection.py | 6 ++++-- rdiff-backup/testing/selectiontest.py | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 2d24ca5..6935381 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -7,6 +7,10 @@ report by Carsten Lorenz). Another fix for long-filenames crash, this time when a long-named directory with files in it gets deleted +Selection fix: empty directories could sometimes be improperly +excluded if certain include expressions involving a non-trailing '**' +were used. Bug reported by Toni Price. + New in v1.0.3 (2005/11/25) -------------------------- diff --git a/rdiff-backup/rdiff_backup/selection.py b/rdiff-backup/rdiff_backup/selection.py index 310aed3..bff1e0c 100644 --- a/rdiff-backup/rdiff_backup/selection.py +++ b/rdiff-backup/rdiff_backup/selection.py @@ -209,10 +209,12 @@ class Select: def Select(self, rp): """Run through the selection functions and return dominant val 0/1/2""" + scanned = 0 # 0, by default, or 2 if prev sel func scanned rp for sf in self.selection_functions: result = sf(rp) - if result == 1 or result == 0 or (result == 2 and rp.isdir()): - return result + if result == 1: return 1 + elif result == 0: return scanned + elif result == 2: scanned = 2 return 1 def ParseArgs(self, argtuples, filelists): diff --git a/rdiff-backup/testing/selectiontest.py b/rdiff-backup/testing/selectiontest.py index 3151bf9..569a94f 100644 --- a/rdiff-backup/testing/selectiontest.py +++ b/rdiff-backup/testing/selectiontest.py @@ -448,4 +448,27 @@ testfiles/select**/2 # verbose = 1) +class CommandTest(unittest.TestCase): + """Test rdiff-backup on actual directories""" + def testEmptyDirInclude(self): + """Make sure empty directories are included with **xx exps + + This checks for a bug present in 1.0.3/1.1.5 and similar. + + """ + outrp = MakeOutputDir() + selrp = rpath.RPath(Globals.local_connection, 'testfiles/seltest') + re_init_dir(selrp) + emptydir = selrp.append('emptydir') + emptydir.mkdir() + + rdiff_backup(1, 1, selrp.path, outrp.path, + extra_options = ("--include **XX " + "--exclude testfiles/seltest/YYYY")) + + outempty = outrp.append('emptydir') + assert outempty.isdir(), outempty + + + if __name__ == "__main__": unittest.main() -- cgit v1.2.1