docker-offlineimap/offlineimap/folder
Janna Martl 25513e9038 fix: don't loose local mails because of maxage
Suppose messages A and B were delivered to the remote folder at
"maxage + 1" days ago.

A was downloaded to the local folder "maxage + 1" days ago, but B was only
downloaded "maxage - 1" days ago (contrived scenario to illustrate the two
things that could happen). The behavior was that B gets deleted from the local
folder, but A did not. The expected behavior is that neither is deleted.

Starting where Base.py: __syncmessagesto_delete(self, dstfolder, statusfolder)
is called where:
 - self is the remote folder
and
 - dstfolder is the local folder.

It defines deletelist to be the list of messages in the status folder
messagelist that aren't in the remote folder messagelist with

  not self.uidexists(uid)

A and B are both in the status folder. They're also both *NOT* in the remote
folder messagelist: this list is formed in IMAP.py: cachemessagelist(), which
calls _msgs_to_fetch(), which only asks the IMAP server for messages that are
"< maxage" days old.

Back to Base.py __syncmessagesto_delete(), look at the call
folder.deletemessages(deletelist), where folder is the local folder. This ends
up calling Maildir.py deletemessage() for each message on the deletelist. But we
see that this methods returns (instead of deleting anything) if the message is
in the local folder's messagelist. This messagelist was created by Maildir.py's
cachemessagelist(), which calls _scanfolder(), which tries to exclude messages
based on maxage. So at this point, we *WANT* A and B to be excluded -- then they
will be spared from deletion. This maxage check calls _iswithinmaxage(), and
actually does the date comparison based on the time found at the beginning of
the message's filename. These filenames were originally created in Maildir.py's
new_message_filename(), which calls _gettimeseq() to get the current time (i.e.
the time of retrieval).

Upshot: A's filename has an older timestamp than B's filename. A is excluded
from the local folder messagelist in _scanfolder(), hence spared from deletion
in deletemessage(); B is not excluded, and is deleted.

This patch does not address the timezone issue. As for the IMAP/timezone issue,
a similar issue is discussed in the thunderbird bug tracker here:

https://bugzilla.mozilla.org/show_bug.cgi?id=886534

In the end, they're solving a different problem, but they agree that
there is really no reliable way of guessing the IMAP server's internal
timezone.

Signed-off-by: Janna Martl <janna.martl109@gmail.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2015-03-09 10:31:54 +01:00
..
__init__.py Use "from . import" for relative imports 2012-02-06 17:41:43 +01:00
Base.py fix: folder/*: never set self.messagelist to None 2015-02-13 17:07:18 +01:00
Gmail.py more style consistency 2015-02-10 17:25:00 +01:00
GmailMaildir.py fix: folder/*: never set self.messagelist to None 2015-02-13 17:07:18 +01:00
IMAP.py fix: folder/*: never set self.messagelist to None 2015-02-13 17:07:18 +01:00
LocalStatus.py fix: folder/*: never set self.messagelist to None 2015-02-13 17:07:18 +01:00
LocalStatusSQLite.py LocalStatusSQLite: labels: don't fail if database returns unexpected None value 2015-02-22 14:15:55 +01:00
Maildir.py fix: don't loose local mails because of maxage 2015-03-09 10:31:54 +01:00
UIDMaps.py LocalStatusSQLite: labels: don't fail if database returns unexpected None value 2015-02-22 14:15:55 +01:00