diff --git a/src/borg/cache.py b/src/borg/cache.py index cd381cd91..c1c703326 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -25,6 +25,7 @@ from .helpers import yes, hostname_is_unique from .helpers import remove_surrogates from .helpers import ProgressIndicatorPercent, ProgressIndicatorMessage from .helpers import set_ec, EXIT_WARNING +from .helpers import truncate_and_unlink from .item import ArchiveItem, ChunkListEntry from .crypto.key import PlaintextKey from .crypto.file_integrity import IntegrityCheckedFile, DetachedIntegrityCheckedFile, FileIntegrityError @@ -693,7 +694,7 @@ class LocalCache(CacheStatsMixin): filename=bin_to_hex(archive_id) + '.compact') as fd: chunk_idx.write(fd) except Exception: - os.unlink(fn_tmp) + truncate_and_unlink(fn_tmp) else: os.rename(fn_tmp, fn)