1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-21 21:57:36 +00:00

cache: write_archive_index: truncate_and_unlink on error

This commit is contained in:
Marian Beermann 2017-07-24 10:45:57 +02:00
parent b85076db6f
commit 2623e330a4

View file

@ -25,6 +25,7 @@
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 @@ def write_archive_index(archive_id, chunk_idx):
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)