From 0d6a9a44daacee1a13fc3aa0696f6b3a02dd0f15 Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 22 Dec 2017 15:37:04 +0100 Subject: [PATCH] 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 --- offlineimap/accounts.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/offlineimap/accounts.py b/offlineimap/accounts.py index 6c63621..6418a8c 100644 --- a/offlineimap/accounts.py +++ b/offlineimap/accounts.py @@ -518,6 +518,9 @@ def syncfolder(account, remotefolder, quick): # emails). localfolder.cachemessagelist(min_date=date) 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: # Update the remote cache list for this new min(uids). remotefolder.cachemessagelist(min_uid=min(uids))