From cf3da168a8a007d0d555fb048608aacdcf5d90f9 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 13 Nov 2017 11:05:46 +1000 Subject: [PATCH] don't error if pasted image in temp folder https://anki.tenderapp.com/discussions/ankidesktop/25805-anki-21-error-reporting --- aqt/editor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aqt/editor.py b/aqt/editor.py index e64f2a025..44a96c184 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -855,6 +855,8 @@ class EditorWebView(AnkiWebView): # hash and rename csum = checksum(open(path, "rb").read()) newpath = "{}-{}{}".format(uname, csum, ext) + if os.path.exists(newpath): + os.unlink(newpath) os.rename(path, newpath) # add to media and return resulting html link