Merge pull request #332 from debanjandhar12/patch-1
Fix storeMediaFile logic
This commit is contained in:
commit
d174099b60
@ -650,8 +650,6 @@ class AnkiConnect:
|
||||
def storeMediaFile(self, filename, data=None, path=None, url=None, skipHash=None, deleteExisting=True):
|
||||
if not (data or path or url):
|
||||
raise Exception('You must provide a "data", "path", or "url" field.')
|
||||
if deleteExisting:
|
||||
self.deleteMediaFile(filename)
|
||||
if data:
|
||||
mediaData = base64.b64decode(data)
|
||||
elif path:
|
||||
@ -669,6 +667,8 @@ class AnkiConnect:
|
||||
|
||||
if skip:
|
||||
return None
|
||||
if deleteExisting:
|
||||
self.deleteMediaFile(filename)
|
||||
return self.media().writeData(filename, mediaData)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user