From fceb06836fd0d7464f18d17b68b869b33c46f630 Mon Sep 17 00:00:00 2001 From: souliane Date: Tue, 25 Mar 2014 14:57:38 +0100 Subject: [PATCH] memory: be sure that local_dir exists before creating a new database --- src/memory/sqlite.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/memory/sqlite.py b/src/memory/sqlite.py index 25d86152..0a006d17 100644 --- a/src/memory/sqlite.py +++ b/src/memory/sqlite.py @@ -82,6 +82,10 @@ class SqliteStorage(object): 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