mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
fix first-time latex generation in a deck with no media dir
This commit is contained in:
parent
87a0e087e5
commit
095ac330b5
1 changed files with 3 additions and 2 deletions
|
@ -117,6 +117,8 @@ def buildImg(deck, latex):
|
||||||
texfile.write(latexPostamble + "\n")
|
texfile.write(latexPostamble + "\n")
|
||||||
texfile.close()
|
texfile.close()
|
||||||
texpath = texpath.encode(sys.getfilesystemencoding())
|
texpath = texpath.encode(sys.getfilesystemencoding())
|
||||||
|
# make sure we have a valid mediaDir
|
||||||
|
deck.mediaDir(create=True)
|
||||||
oldcwd = os.getcwd()
|
oldcwd = os.getcwd()
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
si = subprocess.STARTUPINFO()
|
si = subprocess.STARTUPINFO()
|
||||||
|
@ -135,8 +137,7 @@ def buildImg(deck, latex):
|
||||||
return (False, errmsg % "dvipng")
|
return (False, errmsg % "dvipng")
|
||||||
# add to media
|
# add to media
|
||||||
target = latexImgFile(deck, latex)
|
target = latexImgFile(deck, latex)
|
||||||
shutil.copy2("tmp.png", os.path.join(deck.mediaDir(create=True),
|
shutil.copy2("tmp.png", os.path.join(deck.mediaDir(), target))
|
||||||
target))
|
|
||||||
return (True, target)
|
return (True, target)
|
||||||
finally:
|
finally:
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
|
|
Loading…
Reference in a new issue