PICARD-214: Fix Picard adding numbers on file rename on case insensitive file systems

If a file got renamed and the only change was in casing Picard would append a number on case insensitive file systems (except on Windows). Use os.path.samefile to properly check if the old and new path refer to the same file.
This commit is contained in:
Philipp Wolfer
2020-10-21 21:55:41 +02:00
parent 10b73a198a
commit 75b85d2223

View File

@@ -75,7 +75,6 @@ from picard.util import (
emptydir,
find_best_match,
format_time,
pathcmp,
thread,
tracknum_from_filename,
)
@@ -485,8 +484,8 @@ class File(QtCore.QObject, Item):
os.makedirs(new_dirname)
tmp_filename = new_filename
i = 1
while (not pathcmp(old_filename, new_filename + ext)
and os.path.exists(new_filename + ext)):
while (os.path.exists(new_filename + ext)
and not os.path.samefile(old_filename, new_filename + ext)):
new_filename = "%s (%d)" % (tmp_filename, i)
i += 1
new_filename = new_filename + ext