1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-22 14:11:27 +00:00

cachedir: Add CACHEDIR.TAG file to attic cache dirs

This commit is contained in:
Jonas Borgström 2014-05-01 14:56:21 +02:00
parent bc48488744
commit a87a019608
4 changed files with 14 additions and 4 deletions

View file

@ -10,6 +10,6 @@ Patches and Suggestions
```````````````````````
- Brian Johnson
- Dan Christensen
- Jeremy Maitin-Shepard
- Johann Klähn
- Petros Moisiadis

View file

@ -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
------------

View file

@ -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,

View file

@ -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: