conditionally encode path in media

This commit is contained in:
Damien Elmes 2008-12-11 04:13:57 +09:00
parent 7f9593816c
commit dacd318ffd

View file

@ -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