Improve rename logic for directory name collisions.

This commit is contained in:
SiphonSquirrel 2018-06-03 21:17:22 -04:00
parent 43a391d1bd
commit 274d2d9d21

View File

@ -332,7 +332,12 @@ def update_dir_stucture(book_id, calibrepath):
if titledir != new_titledir: if titledir != new_titledir:
try: try:
new_title_path = os.path.join(os.path.dirname(path), new_titledir) new_title_path = os.path.join(os.path.dirname(path), new_titledir)
os.renames(path, new_title_path) if not os.path.exists(new_title_path):
os.renames(path, new_title_path)
else:
for dir_name, subdir_list, file_list in os.walk(path):
for file in file_list:
os.renames(os.path.join(dir_name, file), os.path.join(new_title_path + dir_name[len(path):], file))
path = new_title_path path = new_title_path
localbook.path = localbook.path.split('/')[0] + '/' + new_titledir localbook.path = localbook.path.split('/')[0] + '/' + new_titledir
except OSError as ex: except OSError as ex: