Create SQLite DB directory if it doesn't exist yet

Also check if DB path doesn't point to a directory.

By: Nick Farrell
GitHub: https://github.com/OfflineIMAP/offlineimap/pull/102
Signed-off-by: Eygene Ryabinkin <rea@codelabs.ru>
This commit is contained in:
Eygene Ryabinkin
2014-08-02 22:23:31 +04:00
parent aa55b38e26
commit 73e2c95acd
2 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os.path
import os
import re
from threading import Lock
from .Base import BaseFolder
@ -51,6 +51,12 @@ class LocalStatusSQLiteFolder(BaseFolder):
self._newfolder = False # flag if the folder is new
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
if not os.path.isdir(dirname):
raise UserWarning("SQLite database path '%s' is not a directory." % dirname)
# dblock protects against concurrent writes in same connection
self._dblock = Lock()