On 2018-07-23 20:47:34 -0700, Kevin J. McCarthy wrote:
> On Tue, Jul 24, 2018 at 04:47:43AM +0200, Vincent Lefevre wrote:
> > On 2018-07-22 09:54:44 -0700, Kevin J. McCarthy wrote:
> > > I think the second time is okay.  The routine is just resorting, and
> > > updating the virtual and v2r fields with the assumption that the actual
> > > visible headers hasn't changed.
> > 
> > mutt_sort_headers can be called in mbox_sync_mailbox after the
> > mailbox has been reopened:
> > 
> >   if (need_sort)
> >     /* if the mailbox was reopened, the thread tree will be invalid so make
> >      * sure to start threading from scratch.  */
> >     mutt_sort_headers (ctx, (need_sort == MUTT_REOPENED));
> 
> Unless I'm missing something, this looks redundant - for the case where
> mbox_check_mailbox() returns new mail or reopen.

Yes, according to debug messages, it seems that there are redundant
mutt_sort_headers calls.

> OP_MAIN_SYNC_FOLDER will end up calling update_index() for either of
> those cases, which will both perform the sort and update vcount/vsize.
> 
> OP_QUIT and OP_MAIN_CHANGE_FOLDER do the same thing.
> 
> But I do notice OP_MAIN_IMAP_LOGOUT_ALL neglected to, and should be fixed.

I don't use IMAP, so that I've never done any check with it.

> > While testing, I've noticed an unrelated bug:
> > 
> > ---Mutt: =test2 [Msg:46/46 Inc:10 
> > 202K/203K]---(date)---------------------(end)-
> > 
> > All messages are visible in the limited view, but vsize is different
> > from the full size. This is not consistent. This happens when starting
> > Mutt on this mailbox and selecting a limited view.
> 
> A quick test didn't show me the problem, so I'll have to play around
> with this.

This occurs when the size of the mbox file is a bit less than a
multiple of 1024. I assume that the bug is present for any size,
but due to rounding, one needs some specific values modulo 1024.
This occurs also with only 1 message; see attached mbox file,
whose size if 973 bytes. There is a 1-byte discrepancy (perhaps
1 per message in the more general case).

In mx.c, vsize is computed as follows:

        ctx->vsize += this_body->length + this_body->offset -
          this_body->hdr_offset;

Ditto in pattern.c:

        Context->vsize += this_body->length + this_body->offset -
          this_body->hdr_offset;

But perhaps the issue comes from the fact that after each message
in an mbox file there must be a newline and it is not included in
length.

This problem doesn't occur with maildir.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
>From a@b.invalid Tue Jul 24 10:58:59 2018
From: a@b.invalid
Subject: test

1. Open this mbox file with Mutt.
2. set status_format="%?L?%L/?%l"
3. Limit to ..

Result: 0.9K/1.0K

Additional text to make the size of the mbox file equal to 973:
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
...............................................................
..........................

Reply via email to