From 7c5abc873e9c4f7460fecd9d26a2a849b12d7116 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 1 Dec 2020 08:12:32 +0530 Subject: [PATCH] Be a bit more robust against external software messing with files in the library folder --- src/calibre/db/backend.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index e6360c2d91..ea099589c7 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -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]): - shutil.copyfile(candidates[0], fmt_path) + 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):