diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index f3e50ea..5acd82a 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -513,6 +513,7 @@ def syncfolder(account, remotefolder, quick): # Load status folder. statusfolder = statusrepos.getfolder(remotefolder.getvisiblename(). replace(remoterepos.getsep(), statusrepos.getsep())) + statusfolder.openfiles() if localfolder.get_uidvalidity() == None: # This is a new folder, so delete the status cache to be diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index 2bfd30e..e5d4ccf 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -154,6 +154,9 @@ class LocalStatusFolder(BaseFolder): self.readstatus(cachefd) cachefd.close() + def openfiles(self): + pass # Closing files is done on a per-transaction basis. + def closefiles(self): pass # Closing files is done on a per-transaction basis. diff --git a/offlineimap/folder/LocalStatusSQLite.py b/offlineimap/folder/LocalStatusSQLite.py index 550154e..1a9f03c 100644 --- a/offlineimap/folder/LocalStatusSQLite.py +++ b/offlineimap/folder/LocalStatusSQLite.py @@ -58,9 +58,11 @@ class LocalStatusSQLiteFolder(BaseFolder): raise UserWarning("SQLite database path '%s' is not a directory."% dirname) - # dblock protects against concurrent writes in same connection. + # This lock protects against concurrent writes in same connection. self._dblock = Lock() + self.connection = None + def openfiles(self): # Try to establish connection, no need for threadsafety in __init__. try: self.connection = sqlite.connect(self.filename, check_same_thread=False) @@ -84,10 +86,10 @@ class LocalStatusSQLiteFolder(BaseFolder): cursor = self.connection.execute( "SELECT value from metadata WHERE key='db_version'") except sqlite.DatabaseError: - #db file missing or corrupt, recreate it. + # db file missing or corrupt, recreate it. self.__create_db() else: - # fetch db version and upgrade if needed + # Fetch db version and upgrade if needed. version = int(cursor.fetchone()[0]) if version < LocalStatusSQLiteFolder.cur_version: self.__upgrade_db(version)