Procházet zdrojové kódy

cache: write_archive_index: truncate_and_unlink on error

Marian Beermann před 8 roky
rodič
revize
2623e330a4
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  1. 2 1
      src/borg/cache.py

+ 2 - 1
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)