From 0f56a27b977ac4bcf5afaf26f6b4183f97f5b7c0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 8 Dec 2021 20:28:54 +0530 Subject: [PATCH] ToC Editor: Workaround an occasional error when closing on Windows if the file being edited is in a DropBox/antivirus prone area --- src/calibre/gui2/actions/toc_edit.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/actions/toc_edit.py b/src/calibre/gui2/actions/toc_edit.py index 72ea093e46..54ac797150 100644 --- a/src/calibre/gui2/actions/toc_edit.py +++ b/src/calibre/gui2/actions/toc_edit.py @@ -164,8 +164,14 @@ class ToCEditAction(InterfaceAction): result_path = job['path'] + '.result' if job['started'] and os.path.exists(result_path): self.jobs.remove(job) - with open(result_path) as f: - ret = int(f.read().strip()) + ret = -1 + + def read(result_path): + nonlocal ret + with open(result_path) as f: + ret = int(f.read().strip()) + + retry_on_fail(read, result_path) retry_on_fail(os.remove, result_path) if ret == 0: db = self.gui.current_db