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::fileSystemFactory* fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path tmpDirPath = store->getFormat()-> utility::file::path tmpDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::TMP_DIRECTORY); folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY);
utility::file::path curDirPath = store->getFormat()-> utility::file::path dstDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY); folderPathToFileSystemPath(m_path,
flags == message::FLAG_RECENT ?
maildirFormat::NEW_DIRECTORY :
maildirFormat::CUR_DIRECTORY);
const utility::file::path::component filename = const utility::file::path::component filename =
maildirUtils::buildFilename(maildirUtils::generateId(), maildirUtils::buildFilename(maildirUtils::generateId(),
@ -855,7 +858,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try try
{ {
ref <utility::file> curDir = fsf->create(curDirPath); ref <utility::file> curDir = fsf->create(dstDirPath);
curDir->createDirectory(true); curDir->createDirectory(true);
} }
catch (exceptions::filesystem_exception&) catch (exceptions::filesystem_exception&)
@ -864,7 +867,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
} }
// Actually add the message // 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 // Append the message to the cache list
messageInfos msgInfos; messageInfos msgInfos;
@ -910,7 +913,8 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath, 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::inputStream& is, const utility::stream::size_type size,
utility::progressListener* progress) utility::progressListener* progress)
{ {
@ -970,7 +974,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// ...then, move it to 'cur' // ...then, move it to 'cur'
try try
{ {
file->rename(curDirPath / filename); file->rename(dstDirPath / filename);
} }
catch (exception& e) catch (exception& e)
{ {
@ -980,7 +984,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// Delete temporary file // Delete temporary file
try try
{ {
ref <utility::file> file = fsf->create(tmpDirPath / filename); file->remove();
ref <utility::file> file = fsf->create(dstDirPath / filename);
file->remove(); file->remove();
} }
catch (exceptions::filesystem_exception&) 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 maildirUtils::buildFilename
(const utility::file::path::component& id, const int flags) (const utility::file::path::component& id, const int flags)
{ {
if (flags == message::FLAG_RECENT)
return id;
else
return (buildFilename(id, buildFlags(flags))); return (buildFilename(id, buildFlags(flags)));
} }
const utility::file::path::component maildirUtils::buildFilename 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 #if VMIME_BUILTIN_PLATFORM_WINDOWS
return (utility::path::component(id.getBuffer() + "-" + flags.getBuffer())); // use dash static const char DELIMITER[] = "-";
#else #else
return (utility::path::component(id.getBuffer() + ":" + flags.getBuffer())); // use colon static const char DELIMITER[] = ":";
#endif #endif
return utility::path::component(id.getBuffer() + DELIMITER + flags.getBuffer());
} }