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):
|
def storeMediaFile(self, filename, data=None, path=None, url=None, skipHash=None, deleteExisting=True):
|
||||||
if not (data or path or url):
|
if not (data or path or url):
|
||||||
raise Exception('You must provide a "data", "path", or "url" field.')
|
raise Exception('You must provide a "data", "path", or "url" field.')
|
||||||
if deleteExisting:
|
|
||||||
self.deleteMediaFile(filename)
|
|
||||||
if data:
|
if data:
|
||||||
mediaData = base64.b64decode(data)
|
mediaData = base64.b64decode(data)
|
||||||
elif path:
|
elif path:
|
||||||
@ -669,6 +667,8 @@ class AnkiConnect:
|
|||||||
|
|
||||||
if skip:
|
if skip:
|
||||||
return None
|
return None
|
||||||
|
if deleteExisting:
|
||||||
|
self.deleteMediaFile(filename)
|
||||||
return self.media().writeData(filename, mediaData)
|
return self.media().writeData(filename, mediaData)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user