From 92e5455eb4a879526ebb1a99515e24801c8ebc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=C5=BBarnowiecki?= Date: Thu, 5 May 2016 19:32:50 +0200 Subject: [PATCH] Inform when maxage/startdate is in the future MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes it might happen that you put wrong date and you except emails to be fetched, but they are not and you do not have an idea why. By raising exception the user will see a proper message telling that he used the wrong date for maxage/startdate property. If someone wants to set a future date intentionally might as well sync in the future. Signed-off-by: Łukasz Żarnowiecki Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/Base.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py index 81174cd..0d37c2f 100644 --- a/offlineimap/folder/Base.py +++ b/offlineimap/folder/Base.py @@ -343,6 +343,10 @@ class BaseFolder(object): raise OfflineImapError("maxage led to year %d. " "Abort syncing."% date[0], OfflineImapError.ERROR.MESSAGE) + if (time.mktime(date) - time.mktime(time.localtime())) > 0: + raise OfflineImapError("maxage led to future date %s. " + "Abort syncing."% maxagestr, + OfflineImapError.ERROR.MESSAGE) return date except ValueError: raise OfflineImapError("invalid maxage value %s"% maxagestr, @@ -364,6 +368,10 @@ class BaseFolder(object): raise OfflineImapError("startdate led to year %d. " "Abort syncing."% date[0], OfflineImapError.ERROR.MESSAGE) + if (time.mktime(date) - time.mktime(time.localtime())) > 0: + raise OfflineImapError("startdate led to future date %s. " + "Abort syncing."% datestr, + OfflineImapError.ERROR.MESSAGE) return date except ValueError: raise OfflineImapError("invalid startdate value %s",