소스 검색

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')