1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-09 13:53:09 +00:00

Fix backwards compatibility of old chunks.archive.d file behavior

In case a file named chunks.archive.d, cache would not create a folder
with that name to store cache chunks archive. We need to support both
the new environment variable and the old "hacky" way of creating a file.
This commit is contained in:
William Bonnaventure 2024-07-14 18:55:19 +02:00
parent 2c364fca40
commit 924952fcdd

View file

@ -478,7 +478,6 @@ class LocalCache(CacheStatsMixin):
self.consider_part_files = consider_part_files
self.timestamp = None
self.txn_active = False
self.do_cache = os.environ.get("BORG_USE_CHUNKS_ARCHIVE", "yes").lower() in ["yes", "1", "true"]
self.path = cache_dir(repository, path)
self.security_manager = SecurityManager(repository)
@ -495,6 +494,13 @@ class LocalCache(CacheStatsMixin):
self.wipe_cache()
self.open()
# new way: tell whether to use the chunks archive via an environment variable:
do_cache_env = os.environ.get("BORG_USE_CHUNKS_ARCHIVE", "yes").lower() in ["yes", "1", "true"]
# backwards compatibility: a user might have replaced the archive_path directory with
# a regular file (as documented in the borg FAQ) to avoid chunks archive creation:
do_cache_fs = os.path.isdir(os.path.join(self.path, "chunks.archive.d"))
self.do_cache = do_cache_env and do_cache_fs
try:
self.security_manager.assert_secure(manifest, key, cache_config=self.cache_config)