Parcourir la source

Only override pack file if it doesn't yet exist.

Jelmer Vernooij il y a 7 ans
Parent
commit
1f098d17a8
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8 0
      dulwich/object_store.py

+ 8 - 0
dulwich/object_store.py

@@ -679,6 +679,14 @@ class DiskObjectStore(PackBasedObjectStore):
             basename = self._get_pack_basepath(entries)
             with GitFile(basename+".idx", "wb") as f:
                 write_pack_index_v2(f, entries, p.get_stored_checksum())
+        if self._pack_cache is None or self._pack_cache_stale():
+            self._update_pack_cache()
+        try:
+            return self._pack_cache[basename]
+        except KeyError:
+            pass
+        else:
+            os.unlink(path)
         os.rename(path, basename + ".pack")
         final_pack = Pack(basename)
         self._add_known_pack(basename, final_pack)