From: Tim Riemenschneider Date: Mon, 9 Jun 2014 18:05:10 +0000 (+0200) Subject: Match tar's "--exclude-caches"-semantic X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d99d16d46f093d6ef895300312ac3b9951f003fa;p=packages%2Fb%2Fbup.git Match tar's "--exclude-caches"-semantic With --exclude-caches, only exclude the directory contents (without the tag-file itself), thus matching tar's semantic (The previous implementation matched tar's "--exclude-caches-all") Signed-off-by: Tim Riemenschneider --- diff --git a/Documentation/bup-index.md b/Documentation/bup-index.md index a2c198d..180e1d1 100644 --- a/Documentation/bup-index.md +++ b/Documentation/bup-index.md @@ -184,8 +184,9 @@ does, due to the accommodations described above. \--exclude-caches -: exclude all directories that contain a file CACHEDIR.TAG, whose - content begins with "Signature: 8a477f597d28d172789f06886806bc55". +: exclude the contents of all directories that contain a file CACHEDIR.TAG, + whose content begins with "Signature: 8a477f597d28d172789f06886806bc55", + except for the directory and the tag file itself. For more information on cachedir-tagging, see http://www.brynosaurus.com/cachedir/ diff --git a/cmd/index-cmd.py b/cmd/index-cmd.py index 2e97315..c003b9b 100755 --- a/cmd/index-cmd.py +++ b/cmd/index-cmd.py @@ -206,7 +206,7 @@ exclude= a path to exclude from the backup (may be repeated) 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-caches exclude directories containing a CACHEDIR.TAG +exclude-caches exclude directories containing a CACHEDIR.TAG, except for the tag file itself 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 4f30ce6..b01d035 100644 --- a/lib/bup/drecurse.py +++ b/lib/bup/drecurse.py @@ -65,14 +65,22 @@ def _recursive_dirlist(prepend, xdev, bup_dir=None, if exclude_caches: tag_filename = 'CACHEDIR.TAG' tag_contents = 'Signature: 8a477f597d28d172789f06886806bc55' - if os.path.exists(prepend+name+tag_filename): - f = open(prepend+name+tag_filename, 'rb') + tag_path = path+tag_filename + if os.path.exists(tag_path): + f = open(tag_path, 'rb') try: data = f.read(len(tag_contents)) finally: f.close() if data == tag_contents: debug1('Skipping %r: excluding cache dir' % (prepend+name)) + try: + st = xstat.lstat(tag_path) + except OSError, e: + add_error(Exception('%s: %s' % (realpath(tag_path), str(e)))) + # CACHEDIR.TAG matched -> only backup the tagfile and the dir-node itself + yield (tag_path, st) + yield (path, pst) continue if bup_dir != None: if os.path.normpath(path) == bup_dir: diff --git a/t/test-index-excludes.sh b/t/test-index-excludes.sh index eea0d13..d51edb1 100755 --- a/t/test-index-excludes.sh +++ b/t/test-index-excludes.sh @@ -15,11 +15,14 @@ WVSTART "exclude-caches" WVPASS touch $D/a WVPASS bup random 128k >$D/b WVPASS mkdir $D/d $D/d/e + WVPASS touch $D/d/file WVPASS bup random 512 >$D/f WVPASS echo 'Signature: 8a477f597d28d172789f06886806bc55' > $D/d/CACHEDIR.TAG WVPASS bup index -ux --exclude-caches $D WVPASS bup save -n exclude $D WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/)" "a b +d f" + WVPASSEQ "$(bup ls exclude/latest/$TOP/$D/d/)" "CACHEDIR.TAG" ) || WVFAIL