diff --git a/AUTHORS b/AUTHORS index cf51bcdf7..3f200d402 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,6 +10,6 @@ Patches and Suggestions ``````````````````````` - Brian Johnson - Dan Christensen +- Jeremy Maitin-Shepard - Johann Klähn - Petros Moisiadis - diff --git a/CHANGES b/CHANGES index e35c704d6..5f20080b4 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,8 @@ Version 0.13 - Experimental Linux and FreeBSD ACL support (#66) - Added support for backup and restore of BSDFlags (OSX, FreeBSD) (#56) - Fix bug where xattrs on symlinks were not correctly restored +- Added cachedir support. CACHEDIR.TAG compatible cache directories + can now be excluded using ``--exclude-caches`` (#74) Version 0.12 ------------ diff --git a/attic/archiver.py b/attic/archiver.py index 5b2757f78..dafab9640 100644 --- a/attic/archiver.py +++ b/attic/archiver.py @@ -427,6 +427,13 @@ def run(self, args=None): if not os.path.exists(cache_dir): os.makedirs(cache_dir) os.chmod(cache_dir, stat.S_IRWXU) + with open(os.path.join(cache_dir, 'CACHEDIR.TAG'), 'w') as fd: + fd.write(textwrap.dedent(""" + Signature: 8a477f597d28d172789f06886806bc55 + # This file is a cache directory tag created by Attic. + # For information about cache directory tags, see: + # http://www.brynosaurus.com/cachedir/ + """).lstrip()) common_parser = argparse.ArgumentParser(add_help=False) common_parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False, diff --git a/attic/helpers.py b/attic/helpers.py index d8a12dc02..619ccfdf9 100644 --- a/attic/helpers.py +++ b/attic/helpers.py @@ -245,6 +245,7 @@ def match(self, path): def __repr__(self): return '%s(%s)' % (type(self), self.pattern) + def is_cachedir(path): """Determines whether the specified path is a cache directory (and therefore should potentially be excluded from the backup) according to @@ -252,7 +253,6 @@ def is_cachedir(path): (http://www.brynosaurus.com/cachedir/spec.html). """ - tag_filename = 'CACHEDIR.TAG' tag_contents = b'Signature: 8a477f597d28d172789f06886806bc55' tag_path = os.path.join(path, 'CACHEDIR.TAG') try: @@ -261,10 +261,11 @@ def is_cachedir(path): tag_data = tag_file.read(len(tag_contents)) if tag_data == tag_contents: return True - except OSError as e: - raise + except OSError: + pass return False + def walk_path(path, skip_inodes=None): st = os.lstat(path) if skip_inodes and (st.st_ino, st.st_dev) in skip_inodes: