maxage: don't consider negative UIDs when computing min UID

With new emails we could have negative UIDs in come use cases. Exclude these
from the list of UIDs. The negative UIDs lead to invalid SEARCH command:

 SEARCH command error: BAD ['Could not parse command']. Data: FMAO19 SEARCH (UID -4:*)

Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/512
Tested-by: https://github.com/shubhamkrm
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2017-12-22 15:37:04 +01:00
parent e802f5fbd5
commit 0d6a9a44da

View File

@ -518,6 +518,9 @@ def syncfolder(account, remotefolder, quick):
# emails). # emails).
localfolder.cachemessagelist(min_date=date) localfolder.cachemessagelist(min_date=date)
uids = localfolder.getmessageuidlist() uids = localfolder.getmessageuidlist()
# Take care to only consider positive uids. Negative UIDs might be
# present due to new emails.
uids = [uid for uid in uids if uid > 0]
if len(uids) > 0: if len(uids) > 0:
# Update the remote cache list for this new min(uids). # Update the remote cache list for this new min(uids).
remotefolder.cachemessagelist(min_uid=min(uids)) remotefolder.cachemessagelist(min_uid=min(uids))