|
From: Len K. <len...@ri...> - 2006-01-31 19:50:15
|
Jamie,
I've noticed a problem with the ReadMail module. If you have "treat mailbox subdirectories as" set to "subdirectories" and a user, say in order to keep forwarded email messages from other servers organized, has the following folder structure:
Inbox
Sentmail
Drafts
Yahoo\inbox
Yahoo\savedmail
Hotmail\inbox
Hotmail\savedmail
when the user switches from "Yahoo\inbox" to "Hotmail\inbox" (ie: an actual mailbox file with the same name, different path) the index listing for one or the other folder gets corrupted. I noticed that the routine called user_index_file() (found in file boxes-lib.pl) returns an index file name to be used by the ReadMail module for the index caching information. This routine produces identical filenames for the above scenario.
A possible fix, which I've implemented in my install is to change the subroutine to the following:
# user_index_file(user|file)
sub user_index_file
{
local $us = $_[0];
$us =~ s/\//_/g;
local $subpath = ((length($_[0]) > length($folders_dir)) && (index($_[0], $folders_dir) == 0)) ? substr($_[0], length($folders_dir)+1) : "";
if (length($subpath))
{
$subpath =~ s/\//\./g;
}
local $f = $_[0] =~ /^\/.*\/([^\/]+)$/ ?
($user_module_config_directory ?
(length($subpath) ?
"$user_module_config_directory/$subpath.findex" :
"$user_module_config_directory/$1.findex") :
"$module_config_directory/$us.findex") :
$user_module_config_directory ?
"$user_module_config_directory/$_[0].index" :
"$module_config_directory/$_[0].index";
local $hn = &get_system_hostname();
return -r $f && !-r "$f.$hn" ? $f : "$f.$hn";
}
The generated index file name now includes the subpath (below the users mailbox_dir) as part of the name. I haven't tested the scenario which fails the REGEXP in the ternary operator, so I'm not 100% sure if this is safe, but it looks safe to me.
Opinions? Corrections?
|