maxage: use the remote folder first to compute min_uid
On each folder scan, we must compute the min_uid. Locally, this is done by relying on the prefix timestamp in the filenames. If for whatever reason they do not reflect the Date header of the email, changing maxage leads to undefined behaviour. To prevent from this, we rather rely on the remote folder. We assume that the remotes are more reliable to provide correct sets of UIDs based on dates than we are. Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/384 Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
d1e770fdcb
commit
f37b97c61b
@ -489,23 +489,21 @@ def syncfolder(account, remotefolder, quick):
|
|||||||
def cachemessagelists_upto_date(date):
|
def cachemessagelists_upto_date(date):
|
||||||
"""Returns messages with uid > min(uids of messages newer than date)."""
|
"""Returns messages with uid > min(uids of messages newer than date)."""
|
||||||
|
|
||||||
# Warning: this makes sense only if the cached list is empty.
|
remotefolder.cachemessagelist(
|
||||||
localfolder.cachemessagelist(min_date=date)
|
min_date=time.gmtime(time.mktime(date) + 24*60*60))
|
||||||
check_uid_validity()
|
uids = remotefolder.getmessageuidlist()
|
||||||
# Local messagelist had date restriction applied already. Restrict
|
localfolder.dropmessagelistcache()
|
||||||
# sync to messages with UIDs >= min_uid from this list.
|
if len(uids) > 0:
|
||||||
#
|
localfolder.cachemessagelist(min_uid=min(uids))
|
||||||
# Local messagelist might contain new messages (with uid's < 0).
|
|
||||||
positive_uids = [uid for uid in localfolder.getmessageuidlist() if uid > 0]
|
|
||||||
if len(positive_uids) > 0:
|
|
||||||
remotefolder.cachemessagelist(min_uid=min(positive_uids))
|
|
||||||
else:
|
else:
|
||||||
# No messages with UID > 0 in range in localfolder.
|
# Remote folder UIDs list is empty for the given range. We still
|
||||||
# date restriction was applied with respect to local dates but
|
# might have valid local UIDs for this range (e.g.: new local
|
||||||
# remote folder timezone might be different from local, so be
|
# emails).
|
||||||
# safe and make sure the range isn't bigger than in local.
|
localfolder.cachemessagelist(min_date=date)
|
||||||
remotefolder.cachemessagelist(
|
uids = localfolder.getmessageuidlist()
|
||||||
min_date=time.gmtime(time.mktime(date) + 24*60*60))
|
if len(uids) > 0:
|
||||||
|
# Update the remote cache list for this new min(uids).
|
||||||
|
remotefolder.cachemessagelist(min_uid=min(uids))
|
||||||
|
|
||||||
def cachemessagelists_startdate(new, partial, date):
|
def cachemessagelists_startdate(new, partial, date):
|
||||||
"""Retrieve messagelists when startdate has been set for
|
"""Retrieve messagelists when startdate has been set for
|
||||||
|
Loading…
Reference in New Issue
Block a user