mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
5158e9ca2a
@ -434,7 +434,8 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
if len(os.listdir(parent)) == 0:
|
if len(os.listdir(parent)) == 0:
|
||||||
self.rmtree(parent, permanent=True)
|
self.rmtree(parent, permanent=True)
|
||||||
curpath = self.library_path
|
curpath = self.library_path
|
||||||
if not self.is_case_sensitive:
|
c1, c2 = current_path.split('/'), path.split('/')
|
||||||
|
if not self.is_case_sensitive and len(c1) == len(c2):
|
||||||
# On case-insensitive systems, title and author renames that only
|
# On case-insensitive systems, title and author renames that only
|
||||||
# change case don't cause any changes to the directories in the file
|
# change case don't cause any changes to the directories in the file
|
||||||
# system. This can lead to having the directory names not match the
|
# system. This can lead to having the directory names not match the
|
||||||
@ -444,12 +445,12 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
# the segment to some temp file name, then rename it back to the
|
# the segment to some temp file name, then rename it back to the
|
||||||
# correct name. Note that the code above correctly handles files in
|
# correct name. Note that the code above correctly handles files in
|
||||||
# the directories, so no need to do them here.
|
# the directories, so no need to do them here.
|
||||||
for oldseg,newseg in zip(current_path.split('/'), path.split('/')):
|
for oldseg, newseg in zip(c1, c2):
|
||||||
if oldseg.lower() == newseg.lower() and oldseg != newseg:
|
if oldseg.lower() == newseg.lower() and oldseg != newseg:
|
||||||
while True:
|
while True:
|
||||||
# need a temp name in the current segment for renames
|
# need a temp name in the current segment for renames
|
||||||
tempname = 'TEMP.%f'%time.time()
|
tempname = os.path.join(curpath, 'TEMP.%f'%time.time())
|
||||||
if not os.path.exists(os.path.join(curpath, tempname)):
|
if not os.path.exists(tempname):
|
||||||
break
|
break
|
||||||
os.rename(os.path.join(curpath, oldseg), tempname)
|
os.rename(os.path.join(curpath, oldseg), tempname)
|
||||||
os.rename(tempname, os.path.join(curpath, newseg))
|
os.rename(tempname, os.path.join(curpath, newseg))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user