Be a bit more robust against external software messing with files in the library folder

This commit is contained in:
Kovid Goyal 2020-12-01 08:12:32 +05:30
parent bfedab34b8
commit 7c5abc873e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1338,7 +1338,12 @@ class DB(object):
except: # If path contains strange characters this throws an exc
candidates = []
if fmt and candidates and os.path.exists(candidates[0]):
try:
shutil.copyfile(candidates[0], fmt_path)
except shutil.SameFileError:
# some other process synced in the file since the last
# os.path.exists()
return candidates[0]
return fmt_path
def cover_abspath(self, book_id, path):