[PATCH 1/2] Re: Another way of locating UID of just saved message
Nicolas Sebrecht
nicolas.s-dev at laposte.net
Wed Aug 3 22:20:34 BST 2011
On Wed, Aug 03, 2011 at 09:14:26PM +0200, Vladimir Marek wrote:
> > The logic looks quiet good to me but I'm still missing why we would need
> > to fetch all headers of new mails. Is there any way to get the first or
> > two messages headers of new mails?
>
> Good question. I wanted to describe my motivation, but forget to do so.
> Originally I have written the patch so that it was fetching just one
> header line of a given type (X-OfflineIMAP). And it worked fine. But I'm
> thinking about this method as a last-hope try before re-downloading the
> message (which can be big). Fetching whole header should not be too big
> and should be hopefully bulletproof.
We don't know. Think about people subscribed to the LKML, python
mailing-list or so, coming back from holidays. Or even an old mailbox
not used for some months (for real life reasons)... We can't assume all
new headers is not as big as a lone mail.
That beeing said, it could be a command-line/offlineimaprc option for
advanced users.
If not, it could still download one or two headers. I guess it's enough.
> > > + found = 0
> > > + for item in result:
> > > + if found == 0 and type(item) == type( () ):
> > > + # Walk just tuples
> > > + if re.search("(?:^|\\r|\\n)%s:\s*%s(?:\\r|\\n)" % (headername, headervalue), item[1], flags=re.IGNORECASE):
> > > + found = 1
> > > + elif found == 1:
> > > + if type(item) == type (""):
> >
> > if type(item) == str:
>
> I thought there's better way, but didn't find it.
>
> > > + if found == 0 and type(item) == type( () ):
>
> Maybe there's better way of specifying array type too?
Sure!
You may want to do:
$ python
>>> type( () )
>>> type( () ) == tuple
to find/test your assumptions.
--
Nicolas Sebrecht
More information about the OfflineIMAP-project
mailing list