From aed276017382ab24df7804d9f0322888d9f23787 Mon Sep 17 00:00:00 2001 From: Jakob Matthes Date: Sun, 10 Mar 2013 19:10:38 +0100 Subject: [PATCH] bup drecurse/index: allow non-directory --exclude and --exclude-from paths. Previously bup only allowed directory exclusions. Signed-off-by: Jakob Matthes Reviewed-by: Gabriel Filion [rlb@defaultvalue.org: change test file from g to j to avoid conflict with subsequent "exclude-from" test; add WVPASS to mkdir so problem is evident; edit commit message.] Signed-off-by: Rob Browning --- lib/bup/drecurse.py | 8 ++++---- t/test.sh | 12 ++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py index 2f4f286..5d49770 100644 --- a/lib/bup/drecurse.py +++ b/lib/bup/drecurse.py @@ -51,6 +51,10 @@ def _dirlist(): def _recursive_dirlist(prepend, xdev, bup_dir=None, excluded_paths=None): for (name,pst) in _dirlist(): + if excluded_paths: + if os.path.normpath(prepend+name) in excluded_paths: + debug1('Skipping %r: excluded.\n' % (prepend+name)) + continue if name.endswith('/'): if xdev != None and pst.st_dev != xdev: debug1('Skipping %r: different filesystem.\n' % (prepend+name)) @@ -59,10 +63,6 @@ def _recursive_dirlist(prepend, xdev, bup_dir=None, excluded_paths=None): if os.path.normpath(prepend+name) == bup_dir: debug1('Skipping BUP_DIR.\n') continue - if excluded_paths: - if os.path.normpath(prepend+name) in excluded_paths: - debug1('Skipping %r: excluded.\n' % (prepend+name)) - continue try: OsFile(name).fchdir() except OSError, e: diff --git a/t/test.sh b/t/test.sh index 644a07b..f1c4142 100755 --- a/t/test.sh +++ b/t/test.sh @@ -363,13 +363,15 @@ touch $D/a WVPASS bup random 128k >$D/b mkdir $D/d $D/d/e WVPASS bup random 512 >$D/f -WVPASS bup index -ux --exclude $D/d $D +WVPASS bup random 512 >$D/j +WVPASS bup index -ux --exclude $D/d --exclude $D/j $D bup save -n exclude $D WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a b f" -mkdir $D/g $D/h -WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h $D +WVPASS mkdir $D/g $D/h +WVPASS bup index -ux --exclude $D/d --exclude $TOP/$D/g --exclude $D/h \ + --exclude $TOP/$D/j $D bup save -n exclude $D WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a b @@ -380,7 +382,8 @@ D=exclude-fromdir.tmp EXCLUDE_FILE=exclude-from.tmp echo "$D/d $TOP/$D/g -$D/h" > $EXCLUDE_FILE +$D/h +$D/i" > $EXCLUDE_FILE force-delete $D mkdir $D export BUP_DIR="$D/.bup" @@ -390,6 +393,7 @@ WVPASS bup random 128k >$D/b mkdir $D/d $D/d/e WVPASS bup random 512 >$D/f mkdir $D/g $D/h +WVPASS bup random 128k > $D/i WVPASS bup index -ux --exclude-from $EXCLUDE_FILE $D bup save -n exclude-from $D WVPASSEQ "$(bup ls exclude-from/latest/$TOP/$D/)" "a -- 2.39.5