Mercurial > libervia-backend
changeset 936:6404df5305e3
memory: be sure that local_dir exists before creating a new database
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 25 Mar 2014 14:57:38 +0100 (2014-03-25) |
parents | 5b2d2f1f05d0 |
children | 255e6953b2c3 |
files | src/memory/sqlite.py |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/memory/sqlite.py Mon Mar 24 16:43:08 2014 +0100 +++ b/src/memory/sqlite.py Tue Mar 25 14:57:38 2014 +0100 @@ -82,6 +82,10 @@ info(_("Connecting database")) new_base = not os.path.exists(db_filename) # do we have to create the database ? + if new_base: # the dir may not exist if it's not the XDG recommended one + dir_ = os.path.dirname(db_filename) + if not os.path.exists(dir_): + os.makedirs(dir_, 0700) self.dbpool = adbapi.ConnectionPool("sqlite3", db_filename, check_same_thread=False) # init_defer is the initialisation deferred, initialisation is ok when all its callbacks have been done