mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
conditionally encode path in media
This commit is contained in:
parent
7f9593816c
commit
dacd318ffd
1 changed files with 5 additions and 2 deletions
|
|
@ -63,6 +63,10 @@ Update media table. If file already exists, don't copy."""
|
|||
if not deck.s.scalar(
|
||||
"select 1 from media where filename = :f",
|
||||
f=newBase):
|
||||
try:
|
||||
path = unicode(path, sys.getfilesystemencoding())
|
||||
except TypeError:
|
||||
pass
|
||||
deck.s.statement("""
|
||||
insert into media (id, filename, size, created, originalPath,
|
||||
description)
|
||||
|
|
@ -72,8 +76,7 @@ values (:id, :filename, :size, :created, :originalPath,
|
|||
filename=newBase,
|
||||
size=newSize,
|
||||
created=time.time(),
|
||||
originalPath=unicode(
|
||||
path, sys.getfilesystemencoding()),
|
||||
originalPath=path,
|
||||
description=os.path.splitext(
|
||||
os.path.basename(path))[0])
|
||||
return newBase
|
||||
|
|
|
|||
Loading…
Reference in a new issue