瀏覽代碼

On Windows, os.rename will thrown WindowsError if the destination already exists. Fixes #448

Akbar Gumbira 8 年之前
父節點
當前提交
4fc96f1179
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      dulwich/object_store.py

+ 5 - 1
dulwich/object_store.py

@@ -567,7 +567,11 @@ class DiskObjectStore(PackBasedObjectStore):
         # Move the pack in.
         entries.sort()
         pack_base_name = self._get_pack_basepath(entries)
-        os.rename(path, pack_base_name + '.pack')
+        try:
+            os.rename(path, pack_base_name + '.pack')
+        except WindowsError:
+            os.remove(pack_base_name + '.pack')
+            os.rename(path, pack_base_name + '.pack')
 
         # Write the index.
         index_file = GitFile(pack_base_name + '.idx', 'wb')