From 932440165a13cc00d921f656a987e697f37156ae Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 4 Jul 2009 15:17:49 +0900 Subject: [PATCH] when files have been modified, make sure to retain originalPath --- anki/media.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/anki/media.py b/anki/media.py index 0963d9e2a..7fc6f7260 100644 --- a/anki/media.py +++ b/anki/media.py @@ -73,6 +73,17 @@ Update media table. If file already exists, don't copy.""" if not deck.s.scalar( "select 1 from media where filename = :f", f=newBase): + if description != "latex": + # if the user has modified a hashed file, try to remember the old + # filename + old = deck.s.scalar( + "select originalPath from media where filename = :s", + s=os.path.basename(origPath)) + if old: + origPath = old + description = os.path.splitext(os.path.basename(origPath))[0] + print "orig", old + print "desc", description try: path = unicode(path, sys.getfilesystemencoding()) except TypeError: