1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

Merge pull request #5775 from ThomasWaldmann/cache-readme-create-once-master

fix repeated cache tag file writing bug
This commit is contained in:
TW 2021-04-19 21:35:07 +02:00 committed by GitHub
commit 318b0446b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -87,13 +87,15 @@ def get_cache_dir():
cache_dir = os.environ.get('BORG_CACHE_DIR', os.path.join(cache_home, 'borg')) cache_dir = os.environ.get('BORG_CACHE_DIR', os.path.join(cache_home, 'borg'))
# Create path if it doesn't exist yet # Create path if it doesn't exist yet
ensure_dir(cache_dir) ensure_dir(cache_dir)
with open(os.path.join(cache_dir, CACHE_TAG_NAME), 'wb') as fd: cache_fn = os.path.join(cache_dir, CACHE_TAG_NAME)
fd.write(CACHE_TAG_CONTENTS) if not os.path.exists(cache_fn):
fd.write(textwrap.dedent(""" with open(cache_fn, 'wb') as fd:
# This file is a cache directory tag created by Borg. fd.write(CACHE_TAG_CONTENTS)
# For information about cache directory tags, see: fd.write(textwrap.dedent("""
# http://www.bford.info/cachedir/spec.html # This file is a cache directory tag created by Borg.
""").encode('ascii')) # For information about cache directory tags, see:
# http://www.bford.info/cachedir/spec.html
""").encode('ascii'))
return cache_dir return cache_dir