Skip to content

Commit 79b705f

Browse files
committed
loose: rename only if needed
Our user was experiencing issue [1] when using a git repository on NTFS mount running on Linux. The current check checks if we are running on Windows, but it should really check if we are on NTFS. And since checking fs type is not that trivial and not efficient, it is simpler and better to just always apply NTFS-specific logic, since it works on other filesystems as well. [1] iterative/dvc#1880 (comment)
1 parent e8e009d commit 79b705f

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

gitdb/db/loose.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,12 @@ def store(self, istream):
225225
if not isdir(obj_dir):
226226
mkdir(obj_dir)
227227
# END handle destination directory
228-
# rename onto existing doesn't work on windows
229-
if os.name == 'nt':
230-
if isfile(obj_path):
231-
remove(tmp_path)
232-
else:
233-
rename(tmp_path, obj_path)
234-
# end rename only if needed
228+
# rename onto existing doesn't work on NTFS
229+
if isfile(obj_path):
230+
remove(tmp_path)
235231
else:
236232
rename(tmp_path, obj_path)
237-
# END handle win32
233+
# end rename only if needed
238234

239235
# make sure its readable for all ! It started out as rw-- tmp file
240236
# but needs to be rwrr

0 commit comments

Comments
 (0)