Inform when maxage/startdate is in the future

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 <dolohow@outlook.com>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Łukasz Żarnowiecki 2016-05-05 19:32:50 +02:00 committed by Nicolas Sebrecht
parent 141abfdf50
commit 92e5455eb4

View File

@ -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",