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