From 6bfaff3ce49012e234081a56b63fbb0fde1ea19f Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sat, 11 Jul 2009 12:39:36 +0000 Subject: [PATCH] maildirFolder::addMessage() : iff FLAG_RECENT is present, add message to 'new' instead of 'cur' (Georg Sauthoff). --- src/net/maildir/maildirFolder.cpp | 21 +++++++++++++-------- src/net/maildir/maildirUtils.cpp | 14 ++++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp index 9a52171c..65abdcf2 100644 --- a/src/net/maildir/maildirFolder.cpp +++ b/src/net/maildir/maildirFolder.cpp @@ -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 curDir = fsf->create(curDirPath); + ref 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 file = fsf->create(tmpDirPath / filename); + file->remove(); + ref file = fsf->create(dstDirPath / filename); file->remove(); } catch (exceptions::filesystem_exception&) diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp index 13311a5f..bb2b69f0 100644 --- a/src/net/maildir/maildirUtils.cpp +++ b/src/net/maildir/maildirUtils.cpp @@ -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()); }