]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
Match tar's "--exclude-caches"-semantic proposed/index-exclude-caches
authorTim Riemenschneider <git@tim-riemenschneider.de>
Mon, 9 Jun 2014 18:05:10 +0000 (20:05 +0200)
committerTim Riemenschneider <git@tim-riemenschneider.de>
Thu, 2 Jul 2015 20:45:07 +0000 (22:45 +0200)
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 <git@tim-riemenschneider.de>
Documentation/bup-index.md
cmd/index-cmd.py
lib/bup/drecurse.py
t/test-index-excludes.sh

index a2c198d71e3d756bce39ec7da4af878673c2cb18..180e1d162ef28a96d13302e8b6fad87f42fa99ec 100644 (file)
@@ -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/
 
index 2e973153fa82048885a8ea393df6497e798aacbc..c003b9bfa003d386dc203a37b8435124d9d9f7d3 100755 (executable)
@@ -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
 """
index 4f30ce6a5db6adcef7e8868efe82b13d7abb8ad9..b01d035713bda05e600f3984edcaf4341319855a 100644 (file)
@@ -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:
index eea0d13694ec5620c86ebdb186cdd6f8d96de53e..d51edb1805b54418c6881a6810889be9e818eaad 100755 (executable)
@@ -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