make sure we pass filename as utf8 to sqlite

This commit is contained in:
Damien Elmes 2012-06-14 08:41:19 +09:00
parent f3a1916c07
commit 4c7f7a7c4b

View file

@ -37,7 +37,7 @@ class Upgrader(object):
def check(self, path): def check(self, path):
"True if deck looks ok." "True if deck looks ok."
with DB(path) as db: with DB(self._utf8(path)) as db:
return self._check(db) return self._check(db)
def _check(self, db): def _check(self, db):
@ -111,12 +111,17 @@ f.id = cards.factId)"""):
def _openDB(self, path): def _openDB(self, path):
self.tmppath = tmpfile(suffix=".anki2") self.tmppath = tmpfile(suffix=".anki2")
shutil.copy(path, self.tmppath) shutil.copy(path, self._utf8(self.tmppath))
self.db = DB(self.tmppath) self.db = DB(self.tmppath)
def _openCol(self): def _openCol(self):
self.col = _Collection(self.db) self.col = _Collection(self.db)
def _utf8(self, txt):
if isinstance(txt, unicode):
return txt.encode("utf8")
return txt
# Schema upgrade # Schema upgrade
###################################################################### ######################################################################