From 38c89c5591c9866ee7f870adeaac4e8d8ba23b0d Mon Sep 17 00:00:00 2001 From: Tim Riemenschneider Date: Sat, 22 Nov 2014 15:41:31 +0100 Subject: [PATCH] Include suggestions of Rob Browning: - don't use set -e in testcase - catch exceptions on read - reword option-help (cherry-picked from proposed/index-exclude-caches branch: 307774fd) Signed-off-by: Tim Riemenschneider (cherry picked from commit 4441324fed583b1c93a43c7dafb354172e0d5369) --- cmd/index-cmd.py | 2 +- lib/bup/drecurse.py | 6 ++++-- t/test-index-excludes.sh | 15 +++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/index-cmd.py b/cmd/index-cmd.py index c07252b..5bdcc43 100755 --- a/cmd/index-cmd.py +++ b/cmd/index-cmd.py @@ -208,7 +208,7 @@ exclude-from= skip --exclude paths in file (may be repeated) exclude-rx= skip paths matching the unanchored regex (may be repeated) exclude-rx-from= skip --exclude-rx patterns in file (may be repeated) exclude-if-present= exclude directory if the given file is present -exclude-caches exclude CACHEDIR.TAG-directories +exclude-caches exclude directories containing a CACHEDIR.TAG v,verbose increase log output (can be used more than once) x,xdev,one-file-system don't cross filesystem boundaries """ diff --git a/lib/bup/drecurse.py b/lib/bup/drecurse.py index 8404f8b..a2d78ae 100644 --- a/lib/bup/drecurse.py +++ b/lib/bup/drecurse.py @@ -71,8 +71,10 @@ def _recursive_dirlist(prepend, xdev, bup_dir=None, tag_contents = 'Signature: 8a477f597d28d172789f06886806bc55' if os.path.exists(prepend+name+tag_filename): f = open(prepend+name+tag_filename, 'rb') - data = f.read(len(tag_contents)) - f.close() + try: + data = f.read(len(tag_contents)) + finally: + f.close() if data == tag_contents: debug1('Skipping %r: excluding cache dir' % (prepend+name)) continue diff --git a/t/test-index-excludes.sh b/t/test-index-excludes.sh index d667a3f..6c5e3a8 100755 --- a/t/test-index-excludes.sh +++ b/t/test-index-excludes.sh @@ -28,19 +28,18 @@ f" WVSTART "exclude-caches" ( - set -e -o pipefail - D="$(wvmktempdir)" - force-delete $D - mkdir $D + D="$(WVPASS wvmktempdir)" || exit $? + WVPASS force-delete $D + WVPASS mkdir $D export BUP_DIR="$D/.bup" WVPASS bup init - touch $D/a + WVPASS touch $D/a WVPASS bup random 128k >$D/b - mkdir $D/d $D/d/e + WVPASS mkdir $D/d $D/d/e WVPASS bup random 512 >$D/f - echo 'Signature: 8a477f597d28d172789f06886806bc55' > $D/d/CACHEDIR.TAG + WVPASS echo 'Signature: 8a477f597d28d172789f06886806bc55' > $D/d/CACHEDIR.TAG WVPASS bup index -ux --exclude-caches $D - bup save -n exclude $D + WVPASS bup save -n exclude $D WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a b f" -- 2.39.5