avoid create the cache tag file on every get_cache_dir call

this re-introduces a race between os.path.exists vs. SaveFile creating that file, but due to the way how SaveFile works, it still makes sure that in the end there is a good cache tag file in place.
This commit is contained in:
Thomas Waldmann 2021-12-07 21:47:15 +01:00
parent 7f5cd2c4d4
commit d0a3b30fdf
1 changed files with 9 additions and 8 deletions

View File

@ -93,6 +93,7 @@ def get_cache_dir():
# Create path if it doesn't exist yet
ensure_dir(cache_dir)
cache_tag_fn = os.path.join(cache_dir, CACHE_TAG_NAME)
if not os.path.exists(cache_tag_fn):
cache_tag_contents = CACHE_TAG_CONTENTS + textwrap.dedent("""
# This file is a cache directory tag created by Borg.
# For information about cache directory tags, see: