1
0
mirror of https://github.com/OfflineIMAP/offlineimap.git synced 2024-06-24 07:26:39 +02:00
offlineimap/offlineimap
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
..
folder fix: don't loose local mails because of maxage 2015-03-09 10:31:54 +01:00
repository more style consistency 2015-02-10 17:25:00 +01:00
ui more style consistency 2015-02-10 17:25:00 +01:00
utils Make OS-default CA certificate file to be requested explicitely 2015-01-18 22:05:49 +03:00
__init__.py v6.5.7-rc2 2015-01-18 21:29:37 +01:00
accounts.py more style consistency 2015-02-10 17:25:00 +01:00
CustomConfig.py Properly re-raise exception to save original tracebacks 2015-01-12 17:51:21 +03:00
emailutil.py more style consistency 2015-01-08 23:36:19 +01:00
error.py more consistent style 2015-01-07 21:31:43 +01:00
globals.py Create global instance of command-line options 2013-02-11 23:34:18 +04:00
imaplib2.py Imaplib2: use proper tracebacks for exceptions 2015-01-19 00:18:14 +03:00
imaplibutil.py imaplibutil: add missing errno import 2015-02-17 10:34:20 +01:00
imapserver.py add proxy support powered by PySocks 2015-02-17 10:34:20 +01:00
imaputil.py more style consistency 2015-02-10 17:25:00 +01:00
init.py more style consistency 2015-02-10 17:25:00 +01:00
localeval.py localeval: avoid redefining 'file' keyword 2015-01-14 17:18:48 +01:00
mbnames.py more consistent style 2015-01-07 21:31:43 +01:00
syncmaster.py Exit "infinite" monitorloop when SyncRunner thread exits 2011-11-02 11:55:05 +01:00
threadutil.py more style consistency 2015-02-10 17:25:00 +01:00