[patch] Re: Fix the logic for updating maildir flags.
nicolas.s-dev at laposte.net
Sat Jan 26 16:41:08 GMT 2013
I believe it was never reviewed/merged. Somewhat old but resending it.
On Tue, Dec 20, 2011 at 01:45:21PM -0500, Rafael Ávila de Espíndola wrote:
> This patch fixes the logic for updating maildir flags.
> I noticed this failing when offlineimap and dovecot accessed the same
> Dovecot adds lowercase flags for keywords the IMAP clients sends it, so
> I had a
> file that was named like
> With the old logic, infostr would be set to infomatch.group(1) which was
> We would then remove the '2,[A-Z]*' leaving only the 'a'. leaving us in
> the end
> with a new file named
> If the old flags were in [A-Z], we should completly strip them. I looks like
> the code intent was to merge them. That is what this change implements. We
> convert the old flags into a set and merge that with the incoming flags.
> After this change, the above case produces a file named
> diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py
> index df5dd2e..90d9164 100644
> --- a/offlineimap/folder/Maildir.py
> +++ b/offlineimap/folder/Maildir.py
> @@ -274,13 +274,14 @@ class MaildirFolder(BaseFolder):
> dir_prefix = 'new'
> - infostr = self.infosep
> infomatch = re.search('(' + self.infosep + '.*)$', newname)
> if infomatch: # If the info string is present..
> - infostr = infomatch.group(1)
> + oldinfo = infomatch.group(1) # of the form :2,...
> + oldflags = set(oldinfo[3:])
> + flags |= oldflags
> newname = newname.split(self.infosep) # Strip off the info string.
> - infostr = re.sub('2,[A-Z]*', '', infostr)
> - infostr += '2,' + ''.join(sorted(flags))
> + infostr = self.infosep + '2,'
> + infostr += ''.join(sorted(flags))
> newname += infostr
> newfilename = os.path.join(dir_prefix, newname)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 995 bytes
Desc: not available
More information about the OfflineIMAP-project