create cache folder if needed

This commit is contained in:
j 2011-02-23 18:32:03 +01:00
parent d72cd7a5e6
commit c5a3298144

View file

@ -91,7 +91,10 @@ class Client(object):
conn.commit() conn.commit()
def _conn(self): def _conn(self):
db_conn = os.path.expanduser(self._config['cache']) dbfile = self._config['cache']
if not os.path.exists(os.path.dirname(dbfile)):
os.makedirs(os.path.dirname(dbfile))
db_conn = os.path.expanduser(dbfile)
conn = sqlite3.connect(db_conn, timeout=10) conn = sqlite3.connect(db_conn, timeout=10)
conn.text_factory = sqlite3.OptimizedUnicode conn.text_factory = sqlite3.OptimizedUnicode
return conn, conn.cursor() return conn, conn.cursor()