Skip to content

Commit e4d2696

Browse files
Update loose.py
1 parent bc195fb commit e4d2696

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Diff for: gitdb/db/loose.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
chmod,
3737
isfile,
3838
remove,
39+
rename,
3940
dirname,
4041
basename,
4142
join
@@ -52,8 +53,8 @@
5253

5354
import tempfile
5455
import os
55-
import shutil
5656
import sys
57+
import time
5758

5859

5960
__all__ = ('LooseObjectDB', )
@@ -225,14 +226,18 @@ def store(self, istream):
225226
if isfile(obj_path):
226227
remove(tmp_path)
227228
else:
228-
shutil.copyfile(tmp_path, obj_path)
229-
remove(tmp_path)
229+
rename(tmp_path, obj_path)
230230
tmp_path = None
231231
# end rename only if needed
232232

233233
# make sure its readable for all ! It started out as rw-- tmp file
234234
# but needs to be rwrr
235-
chmod(obj_path, self.new_objects_mode)
235+
for _ in range(3):
236+
suppress(PermissionError):
237+
chmod(obj_path, self.new_objects_mode)
238+
break
239+
else:
240+
raise PermissionError("Impossible to apply `chmod` to file {}".format(obj_path))
236241
# END handle dry_run
237242

238243
istream.binsha = hex_to_bin(hexsha)

0 commit comments

Comments
 (0)