From 75b85d22236de383ac01290a2cd2d3a3bd98f536 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 21 Oct 2020 21:55:41 +0200 Subject: [PATCH] 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. --- picard/file.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/picard/file.py b/picard/file.py index e08313e01..6c28e97d0 100644 --- a/picard/file.py +++ b/picard/file.py @@ -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