Parcourir la source

Check for existance of index file before opening pack.

This fixes #482:(Concurrent access to a repository on Windows sometimes fails.
OnMaster il y a 8 ans
Parent
commit
c8ebff8c10
1 fichiers modifiés avec 5 ajouts et 2 suppressions
  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: