<<< Date Index >>>     <<< Thread Index >>>

mutt_buffy_check() and st_size of a directory



Hello.
mutt_buffy_check() has the following code fragment at the beginning
of `Incoming' loop (line 311 of buffy.c on tip):

    if (stat (tmp->path, &sb) != 0 || sb.st_size == 0 ||
        (!tmp->magic && (tmp->magic = mx_get_magic (tmp->path)) <= 0))
    {
      /* if the mailbox still doesn't exist, set the newly created flag to
       * be ready for when it does. */
      tmp->newly_created = 1;
      tmp->magic = 0;
      tmp->size = 0;
      continue;
    }

can `sb.st_size == 0' part be changed to the following?
        (S_ISREG(sb.st_mode) && sb.st_size == 0) ||

That part was introduced by this commit:

  http://dev.mutt.org/hg/mutt/rev/472aee12ade2
  Consider empty folders to be non-existent for buffy's purposes.

If I understand correctly, this is a short-cut logic which only works
for an mbox type of mailbox, whose container is a single regular file.
For other types of mailbox whose container is a directory (or a set of
directories), it needs to go through some more logic to tell one mailbox
type from another.  On many systems, st_size for a directory is a positive
value, so this short-cut logic won't be triggered for such mailboxes.
However, the st_size for a directory is (SUS-ly) undefined, so on a system
where st_size for a non-empty directory IS zero, the short-cut logic
unexpectedly triggers, and no new mails are notified for MH or Maildir
mailboxes.  HAMMER on DragonFly is such a filesystem whose directories
always have st_size of 0.

Thanks.