diff --git a/src/messaging/maildir/maildirFolder.cpp b/src/messaging/maildir/maildirFolder.cpp index 0edb0f4c..c3b7e71c 100644 --- a/src/messaging/maildir/maildirFolder.cpp +++ b/src/messaging/maildir/maildirFolder.cpp @@ -282,7 +282,9 @@ void maildirFolder::scanFolder() while (nit->hasMoreElements()) { utility::auto_ptr file = nit->nextElement(); - newMessageFilenames.push_back(file->getFullPath().getLastComponent()); + + if (maildirUtils::isMessageFile(*file)) + newMessageFilenames.push_back(file->getFullPath().getLastComponent()); } delete (nit); // Free directory @@ -294,7 +296,9 @@ void maildirFolder::scanFolder() while (cit->hasMoreElements()) { utility::auto_ptr file = cit->nextElement(); - curMessageFilenames.push_back(file->getFullPath().getLastComponent()); + + if (maildirUtils::isMessageFile(*file)) + curMessageFilenames.push_back(file->getFullPath().getLastComponent()); } delete (cit); // Free directory diff --git a/src/messaging/maildir/maildirUtils.cpp b/src/messaging/maildir/maildirUtils.cpp index 4476b3dd..091fd871 100644 --- a/src/messaging/maildir/maildirUtils.cpp +++ b/src/messaging/maildir/maildirUtils.cpp @@ -88,6 +88,20 @@ const bool maildirUtils::isSubfolderDirectory(const utility::file& file) } +const bool maildirUtils::isMessageFile(const utility::file& file) +{ + // Ignore files which name begins with '.' + if (file.isFile() && + file.getFullPath().getLastComponent().getBuffer().length() >= 1 && + file.getFullPath().getLastComponent().getBuffer()[0] != '.') + { + return (true); + } + + return (false); +} + + const utility::file::path::component maildirUtils::extractId (const utility::file::path::component& filename) { diff --git a/vmime/messaging/maildir/maildirUtils.hpp b/vmime/messaging/maildir/maildirUtils.hpp index c35cc49f..583cdc6b 100644 --- a/vmime/messaging/maildir/maildirUtils.hpp +++ b/vmime/messaging/maildir/maildirUtils.hpp @@ -85,6 +85,14 @@ public: */ static const bool isSubfolderDirectory(const utility::file& file); + /** Test whether the specified file-system object is a message. + * + * @param file reference to a file-system object + * @return true if the specified object is a message file, + * false otherwise + */ + static const bool isMessageFile(const utility::file& file); + /** Extract the unique identifier part of the message filename. * Eg: for the filename "1071577232.28549.m03s:2,RS", it will * return "1071577232.28549.m03s".