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

Merge pull request #8283 from Aztorius/fix-borg-use-chunks-archive-1.4

Fix backwards compatibility of old chunks.archive.d file behavior
This commit is contained in:
TW 2024-07-15 00:17:00 +02:00 committed by GitHub
commit 5ef115b99f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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)