File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 36
36
chmod ,
37
37
isfile ,
38
38
remove ,
39
+ rename ,
39
40
dirname ,
40
41
basename ,
41
42
join
52
53
53
54
import tempfile
54
55
import os
55
- import shutil
56
56
import sys
57
+ import time
57
58
58
59
59
60
__all__ = ('LooseObjectDB' , )
@@ -225,14 +226,18 @@ def store(self, istream):
225
226
if isfile (obj_path ):
226
227
remove (tmp_path )
227
228
else :
228
- shutil .copyfile (tmp_path , obj_path )
229
- remove (tmp_path )
229
+ rename (tmp_path , obj_path )
230
230
tmp_path = None
231
231
# end rename only if needed
232
232
233
233
# make sure its readable for all ! It started out as rw-- tmp file
234
234
# 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 ))
236
241
# END handle dry_run
237
242
238
243
istream .binsha = hex_to_bin (hexsha )
You can’t perform that action at this time.
0 commit comments