owner = None
# list of bytes for last cached mail uids
uids = None
+ # tolerance with which the mailbox was synced
+ tolerance = None
# boolean flag for committing state changes
needs_save = None
# integer for found date conflicts
self.owner = owner
self.uids = []
+ self.tolerance = 0
self.needs_save = False
self.date_conflicts = 0
self.owner = dict["owner"]
self.uids = dict["uids"]
+ self.tolerance = dict["tolerance"]
self.needs_save = False
self.date_conflicts = 0
"""Makes the class printable."""
return self.key
- def synchronize(self, list_ids):
+ def synchronize(self, list_ids, tolerance):
"""Adds new messages to the cache and returns a list of them.
Confirm the changes to a mailbox to finally save it."""
new_ids = []
- if(len(self.uids)==0):
+ # cache is invalid if mailbox is synced with different tolerance
+ if(len(self.uids)==0 or tolerance != self.tolerance):
new_ids = list_ids
else:
for uid in list_ids:
self.uids = list_ids
return new_ids
- def confirm_change(self):
- """Confirm the chages to the cached mailbox."""
+ def confirm_change(self, tolerance):
+ """Confirm the chages to the cached mailbox and specify used tolerance."""
self.needs_save = True
+ self.tolerance = tolerance
return