From 73e2c95acd829282b537df4144a3145b9452c0e7 Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Sat, 2 Aug 2014 22:23:31 +0400 Subject: [PATCH] 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 --- Changelog.rst | 4 ++++ offlineimap/folder/LocalStatusSQLite.py | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Changelog.rst b/Changelog.rst index 0b485ee..082950f 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -8,6 +8,10 @@ ChangeLog OfflineIMAP v6.5.6.1 (YYYY-MM-DD) ================================= +* Create SQLite database directory if it doesn't exist + yet; warn if path is not a directory (Nick Farrell, + GutHub pull #102) + * Fix mangled message headers for servers without UIDPLUS: X-OfflineIMAP was added with preceeding '\n' instead of '\r\n' just before message was uploaded to the IMAP server. diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py index f8921f1..e48545d 100644 --- a/offlineimap/folder/LocalStatusSQLite.py +++ b/offlineimap/folder/LocalStatusSQLite.py @@ -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()