瀏覽代碼

Merge pull request #2876 from enkore/issue/2628

cache: write_archive_index: truncate_and_unlink on error
enkore 8 年之前
父節點
當前提交
836bc33a4d
共有 1 個文件被更改,包括 2 次插入1 次删除
  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)