* Anthony D. Urso (anthonyu@xxxxxxxxx) [031107 08:57]:
> On line 57 of Mail::Box.pm,
> $self->read or return
> if $self->{MB_access} =~ /r|a/;
>
> should be
> $self->read or return
> if $self->{MB_access} =~ /r/;
>
> when newing a Maildir or, most likely, any Dir based mailbox.
>
> As it says in the docs for appendMessages, opening a large folder is
> expensive, so it shouldn't be done unless neccessary.
The situation is a little more complex. Opening a folder is lazy,
so 'read'-ing a folder is not always the same as 'reading all the
messages'. In case of an MH or Maildir folder, the $folder->read only
makes an inventory of all filenames found, and creates lazy-loading
objects for the messages: it does not read the messages.
Of course, this can be made more lazy: in real append mode, you may
not need this. The minimal effort for MH probably is to find highest
message number. For Maildir you probably do not need anything at all.
But even for mbox, a read() is not required.
Questionable is: if opened in append mode, we only write at the end.
However: do we have read access to the messages in the folder as well?
Should we have access => 'r', 'rw', 'a' (== 'w'?), 'ra'
> I've changed it here locally, and would have sent a proper patch, but I
> don't know how to tell if the folder is an mbox.
That's simple: if($self->isa('Mail::Box::Mbox'))
But I don't think that this is sufficient:
$self->read or return
if $self->{MB_access} =~
($self->isa('Mail::Box::Dir') ? m/r/ : m/r|a/;
Probably, it should become:
$self->read if $access =~ m/r/;
$self->collectAppendInfo if $access =~ m/a/;
where collectAppendInfo() for MH only find the highest number and
is empty for Maildir. Does that make sense?
Or maybe even a larger set-up:
$access eq 'r' ? $self->openReadOnly
: $access eq 'a' ? $self->openAppendMode
: $access eq 'w' ? $self->openWriteMode
: ...
Probably, that is the only way to simplify the open() sufficiently to
suite all folder types without trics.
The append() which is implemented now is not optimal in speed, but
reduces the number of cases. That's the reason for the warning in the
docs, and my hesitation to start working on an improvement.
--
MarkOv
------------------------------------------------------------------------
drs Mark A.C.J. Overmeer MARKOV Solutions
Mark@xxxxxxxxxxxx solutions@xxxxxxxxxxxx
http://Mark.Overmeer.net http://solutions.overmeer.net
|