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.
This commit is contained in:
derxe 2019-02-18 16:42:29 +01:00 committed by GitHub
parent 1786110939
commit 9330e23d8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
for field in audio['fields']: