mirror of https://github.com/borgbackup/borg.git
Merge pull request #2876 from enkore/issue/2628
cache: write_archive_index: truncate_and_unlink on error
This commit is contained in:
commit
836bc33a4d
|
@ -25,6 +25,7 @@ from .helpers import yes, hostname_is_unique
|
||||||
from .helpers import remove_surrogates
|
from .helpers import remove_surrogates
|
||||||
from .helpers import ProgressIndicatorPercent, ProgressIndicatorMessage
|
from .helpers import ProgressIndicatorPercent, ProgressIndicatorMessage
|
||||||
from .helpers import set_ec, EXIT_WARNING
|
from .helpers import set_ec, EXIT_WARNING
|
||||||
|
from .helpers import truncate_and_unlink
|
||||||
from .item import ArchiveItem, ChunkListEntry
|
from .item import ArchiveItem, ChunkListEntry
|
||||||
from .crypto.key import PlaintextKey
|
from .crypto.key import PlaintextKey
|
||||||
from .crypto.file_integrity import IntegrityCheckedFile, DetachedIntegrityCheckedFile, FileIntegrityError
|
from .crypto.file_integrity import IntegrityCheckedFile, DetachedIntegrityCheckedFile, FileIntegrityError
|
||||||
|
@ -693,7 +694,7 @@ class LocalCache(CacheStatsMixin):
|
||||||
filename=bin_to_hex(archive_id) + '.compact') as fd:
|
filename=bin_to_hex(archive_id) + '.compact') as fd:
|
||||||
chunk_idx.write(fd)
|
chunk_idx.write(fd)
|
||||||
except Exception:
|
except Exception:
|
||||||
os.unlink(fn_tmp)
|
truncate_and_unlink(fn_tmp)
|
||||||
else:
|
else:
|
||||||
os.rename(fn_tmp, fn)
|
os.rename(fn_tmp, fn)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue