diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index 19f8b0247f..9259fc628b 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -951,7 +951,8 @@ class DB(object): if samefile(dest, path): # Ensure that the file has the same case as dest try: - os.rename(path, dest) + if path != dest: + os.rename(path, dest) except: pass # Nothing too catastrophic happened, the cases mismatch, that's all else: @@ -964,7 +965,7 @@ class DB(object): dest.flush() elif dest: if samefile(dest, path): - if not self.is_case_sensitive: + if not self.is_case_sensitive and path != dest: # Ensure that the file has the same case as dest try: os.rename(path, dest) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index d398c3da3d..376eb52c3c 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1347,7 +1347,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): if samefile(path, dest): # Ensure that the file has the same case as dest try: - os.rename(path, dest) + if path != dest: + os.rename(path, dest) except: pass # Nothing too catastrophic happened, the cases mismatch, that's all else: @@ -1360,7 +1361,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): dest.flush() elif dest: if samefile(dest, path): - if not self.is_case_sensitive: + if not self.is_case_sensitive and path != dest: # Ensure that the file has the same case as dest try: os.rename(path, dest)