]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
Match tar's "--exclude-caches"-semantic
authorTim Riemenschneider <git@tim-riemenschneider.de>
Sat, 22 Nov 2014 14:46:55 +0000 (15:46 +0100)
committerMichael Howe <michael@michaelhowe.org>
Wed, 21 Oct 2015 21:59:58 +0000 (22:59 +0100)
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")

(cherr-picked from proposed/index-exclude-caches branch: e1f95c0d)
Signed-off-by: Tim Riemenschneider <git@tim-riemenschneider.de>
(cherry picked from commit 1c5ffa75605ba570b913fb3919c0edda8c7ecfaa)

Documentation/bup-index.md
cmd/index-cmd.py
lib/bup/drecurse.py
t/test-index-excludes.sh

index 7b5a6babd6f187ab0b72b999958bc18e04e010a0..1638d6579aabeee4a9925a6dd8e85d095f159b05 100644 (file)
@@ -189,8 +189,9 @@ does, due to the accommodations described above.
     from backup.
 
 \--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/
 
index 5bdcc4373a474467aa52128bc28cc387c8b51503..833206a71ca4ca69309cc9568b25ba6bc3823129 100755 (executable)
@@ -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 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
 """
index a2d78aefbd3ee3a007bb546ecb7861d152549702..ec24c8cdbb321bc47f274319e03b0af4c6285128 100644 (file)
@@ -69,14 +69,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:
index 6c5e3a828668a0c5a734a50d5c4e656609f2ff31..04a93a0f53c31066de659c353a3ec90dfcf1abb2 100755 (executable)
@@ -36,11 +36,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