From 9330e23d8a28ae6aac921b19634aba8ece071107 Mon Sep 17 00:00:00 2001 From: derxe <42929423+derxe@users.noreply.github.com> Date: Mon, 18 Feb 2019 16:42:29 +0100 Subject: [PATCH] Bug fix, duplicate audio filenames Fix the bug where old file name was referenced in the audio field. The problem was, if the audio file we were trying to save already existed it got automatically saved with a different name (the number was appended to the end), but inside the card the incorrect old filename was referenced. --- AnkiConnect.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AnkiConnect.py b/AnkiConnect.py index c6bb2a4..7b7cb81 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -713,11 +713,11 @@ class AnkiConnect: skip = skipHash == m.hexdigest() if not skip: + audioFilename = self.media().writeData(audio['filename'], data) for field in audio['fields']: if field in ankiNote: - ankiNote[field] += u'[sound:{}]'.format(audio['filename']) - - self.media().writeData(audio['filename'], data) + ankiNote[field] += u'[sound:{}]'.format(audioFilename) + except Exception as e: errorMessage = str(e).replace("&", "&").replace("<", "<").replace(">", ">") for field in audio['fields']: