avoid removing of data when user removed a maildir

When a maildir is removed it must be considered new for the sync. However, the
local cache of the folder remains. This means the sync of the folder removes all
the missing emails.

Avoid loosing of data for users not aware of the local cache by removing any
pre-existing status cache of a folder when we actually want to create the
database.

Improve style.

Github-fix: https://github.com/OfflineIMAP/offlineimap/issues/333
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht
2016-06-17 19:47:37 +02:00
parent 08e17de7e2
commit 1410a391bc
5 changed files with 63 additions and 42 deletions

View File

@ -88,6 +88,14 @@ class LocalStatusSQLiteFolder(BaseFolder):
if version < LocalStatusSQLiteFolder.cur_version:
self.__upgrade_db(version)
def purge(self):
"""Remove any pre-existing database."""
try:
os.unlink(self.filename)
except OSError as e:
self.ui.debug('', "could not remove file %s: %s"%
(self.filename, e))
def storesmessages(self):
return False