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 <[email protected]>
---
 offlineimap/folder/Base.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/offlineimap/folder/Base.py b/offlineimap/folder/Base.py
index 14b0867..f284142 100644
--- a/offlineimap/folder/Base.py
+++ b/offlineimap/folder/Base.py
@@ -335,6 +335,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,
@@ -356,6 +360,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",
-- 
2.8.2


_______________________________________________
OfflineIMAP-project mailing list: [email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project

OfflineIMAP homepages:
- https://github.com/OfflineIMAP
- http://offlineimap.org

Reply via email to