瀏覽代碼

Check for existance of index file before opening pack.

This fixes #482:(Concurrent access to a repository on Windows sometimes fails.
OnMaster 8 年之前
父節點
當前提交
c8ebff8c10
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      dulwich/object_store.py

+ 5 - 2
dulwich/object_store.py

@@ -481,9 +481,12 @@ class DiskObjectStore(PackBasedObjectStore):
         pack_files = set()
         for name in pack_dir_contents:
             assert isinstance(name, basestring if sys.version_info[0] == 2 else str)
-            # TODO: verify that idx exists first
             if name.startswith("pack-") and name.endswith(".pack"):
-                pack_files.add(name[:-len(".pack")])
+                # verify that idx exists first (otherwise the pack was not yet fully written)
+                idx_name = os.path.splitext(name)[0] + ".idx"
+                if idx_name in pack_dir_contents:
+                    pack_name = name[:-len(".pack")]
+                    pack_files.add(pack_name)
 
         # Open newly appeared pack files
         for f in pack_files: