mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Replaced os.rename with atomic os.replace
This should eliminate last problems with file locks on Windows
This commit is contained in:
@@ -104,7 +104,7 @@ class CBxArchive:
|
|||||||
for f in os.listdir(os.path.join(targetdir, adir[0])):
|
for f in os.listdir(os.path.join(targetdir, adir[0])):
|
||||||
# If directory names contain UTF-8 chars shutil.move can't clean up the mess alone
|
# If directory names contain UTF-8 chars shutil.move can't clean up the mess alone
|
||||||
if os.path.isdir(os.path.join(targetdir, f)):
|
if os.path.isdir(os.path.join(targetdir, f)):
|
||||||
os.rename(os.path.join(targetdir, adir[0], f), os.path.join(targetdir, adir[0], f + '-A'))
|
os.replace(os.path.join(targetdir, adir[0], f), os.path.join(targetdir, adir[0], f + '-A'))
|
||||||
f += '-A'
|
f += '-A'
|
||||||
move(os.path.join(targetdir, adir[0], f), targetdir)
|
move(os.path.join(targetdir, adir[0], f), targetdir)
|
||||||
os.rmdir(os.path.join(targetdir, adir[0]))
|
os.rmdir(os.path.join(targetdir, adir[0]))
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ def sanitizeTree(filetree):
|
|||||||
newKey = os.path.join(root, slugified + splitname[1])
|
newKey = os.path.join(root, slugified + splitname[1])
|
||||||
key = os.path.join(root, name)
|
key = os.path.join(root, name)
|
||||||
if key != newKey:
|
if key != newKey:
|
||||||
os.rename(key, newKey)
|
os.replace(key, newKey)
|
||||||
for name in dirs:
|
for name in dirs:
|
||||||
if name.startswith('.'):
|
if name.startswith('.'):
|
||||||
os.remove(os.path.join(root, name))
|
os.remove(os.path.join(root, name))
|
||||||
@@ -686,7 +686,7 @@ def sanitizeTree(filetree):
|
|||||||
newKey = os.path.join(root, slugified)
|
newKey = os.path.join(root, slugified)
|
||||||
key = os.path.join(root, name)
|
key = os.path.join(root, name)
|
||||||
if key != newKey:
|
if key != newKey:
|
||||||
os.rename(key, newKey)
|
os.replace(key, newKey)
|
||||||
return chapterNames
|
return chapterNames
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user