From aef88cc1f85ca021935b1ac09fd12652500a9ddf Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Fri, 22 Aug 2014 17:43:36 +0400 Subject: [PATCH] Fix label processing in GmailMaildir Commit 7df765cfdb4096a33f35bf709db6820a6c2c79fd introduced regression: GmailMaildir caches labels in its own function and it was testing the presence of the 'labels' key in message descriptor. But 7df765cf changed descriptor initialization and this key is always present. So now we have 'labels_cached' flag that tells us if labels were already cached or not. Signed-off-by: Eygene Ryabinkin --- offlineimap/folder/GmailMaildir.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/offlineimap/folder/GmailMaildir.py b/offlineimap/folder/GmailMaildir.py index b62b701..2cab213 100644 --- a/offlineimap/folder/GmailMaildir.py +++ b/offlineimap/folder/GmailMaildir.py @@ -59,7 +59,8 @@ class GmailMaildirFolder(MaildirFolder): # Interface from BaseFolder def msglist_item_initializer(self, uid): - return {'flags': set(), 'labels': set(), 'filename': '/no-dir/no-such-file/', 'mtime': 0} + return {'flags': set(), 'labels': set(), 'labels_cached': False, + 'filename': '/no-dir/no-such-file/', 'mtime': 0} def cachemessagelist(self): @@ -72,9 +73,10 @@ class GmailMaildirFolder(MaildirFolder): filepath = os.path.join(self.getfullname(), msg['filename']) msg['mtime'] = long(os.stat(filepath).st_mtime) + def getmessagelabels(self, uid): # Labels are not cached in cachemessagelist because it is too slow. - if not 'labels' in self.messagelist[uid]: + if not self.messagelist[uid]['labels_cached']: filename = self.messagelist[uid]['filename'] filepath = os.path.join(self.getfullname(), filename) @@ -88,10 +90,11 @@ class GmailMaildirFolder(MaildirFolder): self.messagelist[uid]['labels'] = \ imaputil.labels_from_header(self.labelsheader, self.getmessageheader(content, self.labelsheader)) - + self.messagelist[uid]['labels_cached'] = True return self.messagelist[uid]['labels'] + def getmessagemtime(self, uid): if not 'mtime' in self.messagelist[uid]: return 0