maildirFolder::addMessage() : iff FLAG_RECENT is present, add message to 'new' instead of 'cur' (Georg Sauthoff).

This commit is contained in:
Vincent Richard 2009-07-11 12:39:36 +00:00
parent f36ccb2558
commit 6bfaff3ce4
2 changed files with 23 additions and 12 deletions

View File

@ -835,9 +835,12 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
utility::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path tmpDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::TMP_DIRECTORY);
utility::file::path curDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY);
utility::file::path dstDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path,
flags == message::FLAG_RECENT ?
maildirFormat::NEW_DIRECTORY :
maildirFormat::CUR_DIRECTORY);
const utility::file::path::component filename =
maildirUtils::buildFilename(maildirUtils::generateId(),
@ -855,7 +858,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try
{
ref <utility::file> curDir = fsf->create(curDirPath);
ref <utility::file> curDir = fsf->create(dstDirPath);
curDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@ -864,7 +867,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
}
// Actually add the message
copyMessageImpl(tmpDirPath, curDirPath, filename, is, size, progress);
copyMessageImpl(tmpDirPath, dstDirPath, filename, is, size, progress);
// Append the message to the cache list
messageInfos msgInfos;
@ -910,7 +913,8 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
const utility::file::path& curDirPath, const utility::file::path::component& filename,
const utility::file::path& dstDirPath,
const utility::file::path::component& filename,
utility::inputStream& is, const utility::stream::size_type size,
utility::progressListener* progress)
{
@ -970,7 +974,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// ...then, move it to 'cur'
try
{
file->rename(curDirPath / filename);
file->rename(dstDirPath / filename);
}
catch (exception& e)
{
@ -980,7 +984,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// Delete temporary file
try
{
ref <utility::file> file = fsf->create(tmpDirPath / filename);
file->remove();
ref <utility::file> file = fsf->create(dstDirPath / filename);
file->remove();
}
catch (exceptions::filesystem_exception&)

View File

@ -129,18 +129,24 @@ const utility::file::path::component maildirUtils::buildFlags(const int flags)
const utility::file::path::component maildirUtils::buildFilename
(const utility::file::path::component& id, const int flags)
{
return (buildFilename(id, buildFlags(flags)));
if (flags == message::FLAG_RECENT)
return id;
else
return (buildFilename(id, buildFlags(flags)));
}
const utility::file::path::component maildirUtils::buildFilename
(const utility::file::path::component& id, const utility::file::path::component& flags)
(const utility::file::path::component& id,
const utility::file::path::component& flags)
{
#if VMIME_BUILTIN_PLATFORM_WINDOWS
return (utility::path::component(id.getBuffer() + "-" + flags.getBuffer())); // use dash
static const char DELIMITER[] = "-";
#else
return (utility::path::component(id.getBuffer() + ":" + flags.getBuffer())); // use colon
static const char DELIMITER[] = ":";
#endif
return utility::path::component(id.getBuffer() + DELIMITER + flags.getBuffer());
}