diff options
Diffstat (limited to 'src/maildir.cc')
-rw-r--r-- | src/maildir.cc | 387 |
1 files changed, 167 insertions, 220 deletions
diff --git a/src/maildir.cc b/src/maildir.cc index 11f472c..5071a1a 100644 --- a/src/maildir.cc +++ b/src/maildir.cc @@ -4,30 +4,32 @@ * @author Andreas Aardal Hanssen * @date 2002-2005 * ----------------------------------------------------------------- **/ -#include <iostream> -#include <iomanip> +#include "maildir.h" + +#include "convert.h" +#include "globals.h" +#include "iodevice.h" +#include "iofactory.h" +#include "maildirmessage.h" +#include "pendingupdates.h" +#include "session.h" +#include "status.h" + #include <algorithm> +#include <iomanip> +#include <iostream> #include <ctype.h> -#include <dirent.h> #include <errno.h> -#include <fcntl.h> #include <stdio.h> + +#include <dirent.h> +#include <fcntl.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> -#include "convert.h" -#include "iodevice.h" -#include "iofactory.h" -#include "maildir.h" -#include "maildirmessage.h" -#include "pendingupdates.h" -#include "session.h" -#include "status.h" -#include "globals.h" - using namespace ::std; using namespace Binc; @@ -35,16 +37,18 @@ using namespace Binc; static int numDeliveries = 0; //------------------------------------------------------------------------ -Maildir::iterator::iterator(void) -{ -} +Maildir::iterator::iterator(void) {} //------------------------------------------------------------------------ Maildir::iterator::iterator(Maildir *home, - MessageMap::iterator it, - const SequenceSet &_bset, - unsigned int _mod) - : BaseIterator(1), mailbox(home), bset(_bset), mod(_mod), i(it) + MessageMap::iterator it, + const SequenceSet &_bset, + unsigned int _mod) + : BaseIterator(1) + , mailbox(home) + , bset(_bset) + , mod(_mod) + , i(it) { uidmax = home->getMaxUid(); sqnrmax = home->getMaxSqnr(); @@ -52,14 +56,17 @@ Maildir::iterator::iterator(Maildir *home, //------------------------------------------------------------------------ Maildir::iterator::iterator(const iterator ©) - : BaseIterator(copy.sqnr), mailbox(copy.mailbox), - bset(copy.bset), mod(copy.mod), i(copy.i), uidmax(copy.uidmax), - sqnrmax(copy.sqnrmax) -{ -} + : BaseIterator(copy.sqnr) + , mailbox(copy.mailbox) + , bset(copy.bset) + , mod(copy.mod) + , i(copy.i) + , uidmax(copy.uidmax) + , sqnrmax(copy.sqnrmax) +{} //------------------------------------------------------------------------ -Maildir::iterator &Maildir::iterator::operator =(const iterator ©) +Maildir::iterator &Maildir::iterator::operator=(const iterator ©) { sqnr = copy.sqnr; mailbox = copy.mailbox; @@ -72,9 +79,7 @@ Maildir::iterator &Maildir::iterator::operator =(const iterator ©) } //------------------------------------------------------------------------ -Maildir::iterator::~iterator(void) -{ -} +Maildir::iterator::~iterator(void) {} //------------------------------------------------------------------------ MaildirMessage &Maildir::iterator::curMessage(void) @@ -83,13 +88,13 @@ MaildirMessage &Maildir::iterator::curMessage(void) } //------------------------------------------------------------------------ -Message &Maildir::iterator::operator *(void) +Message &Maildir::iterator::operator*(void) { return curMessage(); } //------------------------------------------------------------------------ -void Maildir::iterator::operator ++(void) +void Maildir::iterator::operator++(void) { ++i; ++sqnr; @@ -97,14 +102,14 @@ void Maildir::iterator::operator ++(void) } //------------------------------------------------------------------------ -bool Maildir::iterator::operator ==(const BaseIterator &a) const +bool Maildir::iterator::operator==(const BaseIterator &a) const { const iterator *b = dynamic_cast<const iterator *>(&a); return b ? (i == b->i) : false; } //------------------------------------------------------------------------ -bool Maildir::iterator::operator !=(const BaseIterator &a) const +bool Maildir::iterator::operator!=(const BaseIterator &a) const { return !((*this) == a); } @@ -113,8 +118,7 @@ bool Maildir::iterator::operator !=(const BaseIterator &a) const void Maildir::iterator::reposition(void) { for (;;) { - if (i == mailbox->messages.end()) - break; + if (i == mailbox->messages.end()) break; Message &message = curMessage(); if ((mod & SKIP_EXPUNGED) && message.isExpunged()) { @@ -124,17 +128,15 @@ void Maildir::iterator::reposition(void) bool inset = false; if (mod & SQNR_MODE) { - if (bset.isInSet(sqnr) || (!bset.isLimited() && sqnr == sqnrmax)) - inset = true; + if (bset.isInSet(sqnr) || (!bset.isLimited() && sqnr == sqnrmax)) inset = true; } else { if (bset.isInSet(message.getUID()) || (!bset.isLimited() && message.getUID() == uidmax)) - inset = true; + inset = true; } if (!inset) { ++i; - if (!message.isExpunged()) - ++sqnr; + if (!message.isExpunged()) ++sqnr; continue; } @@ -143,8 +145,7 @@ void Maildir::iterator::reposition(void) } //------------------------------------------------------------------------ -Mailbox::iterator Maildir::begin(const SequenceSet &bset, - unsigned int mod) const +Mailbox::iterator Maildir::begin(const SequenceSet &bset, unsigned int mod) const { beginIterator = iterator((Maildir *)this, messages.begin(), bset, mod); beginIterator.reposition(); @@ -155,8 +156,7 @@ Mailbox::iterator Maildir::begin(const SequenceSet &bset, //------------------------------------------------------------------------ Mailbox::iterator Maildir::end(void) const { - endIterator = iterator((Maildir *)this, messages.end(), - endIterator.bset, endIterator.mod); + endIterator = iterator((Maildir *)this, messages.end(), endIterator.bset, endIterator.mod); return Mailbox::iterator(endIterator); } @@ -165,7 +165,7 @@ void Maildir::iterator::erase(void) { MessageMap::iterator iter = i; ++iter; - + MaildirMessageCache::getInstance().removeStatus(&curMessage()); mailbox->index.remove(i->second.getUnique()); mailbox->messages.erase(i); @@ -187,9 +187,7 @@ Maildir::Maildir(void) : Mailbox() } //------------------------------------------------------------------------ -Maildir::~Maildir(void) -{ -} +Maildir::~Maildir(void) {} //------------------------------------------------------------------------ void Maildir::setPath(const string &path_in) @@ -198,63 +196,56 @@ void Maildir::setPath(const string &path_in) } //------------------------------------------------------------------------ -bool Maildir::getUpdates(bool doscan, unsigned int type, - PendingUpdates &updates, bool forceScan) +bool Maildir::getUpdates(bool doscan, unsigned int type, PendingUpdates &updates, bool forceScan) { - if (doscan && scan(forceScan) != Success) - return false; + if (doscan && scan(forceScan) != Success) return false; unsigned int exists = 0; unsigned int recent = 0; bool displayExists = false; // count messages, find recent - if (!readOnly && (type & PendingUpdates::EXPUNGE)) { - Mailbox::iterator i = begin(SequenceSet::all(), - INCLUDE_EXPUNGED | SQNR_MODE); + if (!readOnly && (type & PendingUpdates::EXPUNGE)) { + Mailbox::iterator i = begin(SequenceSet::all(), INCLUDE_EXPUNGED | SQNR_MODE); while (i != end()) { Message &message = *i; if (message.isExpunged()) { - updates.addExpunged(i.getSqnr()); - i.erase(); - mailboxchanged = true; - displayExists = true; + updates.addExpunged(i.getSqnr()); + i.erase(); + mailboxchanged = true; + displayExists = true; } else - ++i; + ++i; } } - Mailbox::iterator i = begin(SequenceSet::all(), - INCLUDE_EXPUNGED | SQNR_MODE); + Mailbox::iterator i = begin(SequenceSet::all(), INCLUDE_EXPUNGED | SQNR_MODE); for (; i != end(); ++i) { - Message & message = *i; + Message &message = *i; // at this point, there is a message that is not expunged ++exists; if (message.getStdFlags() & Message::F_RECENT) ++recent; } - if (displayExists || exists != oldexists) - updates.setExists(oldexists = exists); + if (displayExists || exists != oldexists) updates.setExists(oldexists = exists); + + if (recent != oldrecent) updates.setRecent(oldrecent = recent); - if (recent != oldrecent) - updates.setRecent(oldrecent = recent); - - if (type & PendingUpdates::FLAGS) { + if (type & PendingUpdates::FLAGS) { Mailbox::iterator i = begin(SequenceSet::all(), SQNR_MODE); for (; i != end(); ++i) { Message &message = *i; if (message.hasFlagsChanged()) { int flags = message.getStdFlags(); - - updates.addFlagUpdates(i.getSqnr(), message.getUID(), flags, - message.getCustomFlags()); + + updates.addFlagUpdates(i.getSqnr(), message.getUID(), flags, message.getCustomFlags()); message.setFlagsUnchanged(); } } - } + } return true; } @@ -264,12 +255,9 @@ bool Maildir::isMailbox(const std::string &s_in) const { struct stat mystat; - return ((stat((s_in + "/cur").c_str(), &mystat) == 0 - && S_ISDIR(mystat.st_mode)) - && (stat((s_in + "/new").c_str(), &mystat) == 0 - && S_ISDIR(mystat.st_mode)) - && (stat((s_in + "/tmp").c_str(), &mystat) == 0 - && S_ISDIR(mystat.st_mode))); + return ((stat((s_in + "/cur").c_str(), &mystat) == 0 && S_ISDIR(mystat.st_mode)) + && (stat((s_in + "/new").c_str(), &mystat) == 0 && S_ISDIR(mystat.st_mode)) + && (stat((s_in + "/tmp").c_str(), &mystat) == 0 && S_ISDIR(mystat.st_mode))); } //------------------------------------------------------------------------ @@ -291,12 +279,10 @@ bool Maildir::isMarked(const std::string &s_in) const DIR *dirp = opendir((s_in + "/new").c_str()); if (dirp == 0) return false; - struct dirent *direntp; + struct dirent *direntp; while ((direntp = readdir(dirp)) != 0) { string s = direntp->d_name; - if (s[0] != '.' - && s.find('/') == string::npos - && s.find(':') == string::npos) { + if (s[0] != '.' && s.find('/') == string::npos && s.find(':') == string::npos) { closedir(dirp); return true; } @@ -307,24 +293,21 @@ bool Maildir::isMarked(const std::string &s_in) const } //------------------------------------------------------------------------ -unsigned int Maildir::getStatusID(const string &path) const +unsigned int Maildir::getStatusID(const string &path) const { unsigned int statusid = 0; struct stat mystat; - if (stat((path + "/new/").c_str(), &mystat) == 0) - statusid = mystat.st_ctime; + if (stat((path + "/new/").c_str(), &mystat) == 0) statusid = mystat.st_ctime; - if (stat((path + "/cur/").c_str(), &mystat) == 0) - statusid += mystat.st_ctime; + if (stat((path + "/cur/").c_str(), &mystat) == 0) statusid += mystat.st_ctime; - if (stat((path + "/bincimap-cache").c_str(), &mystat) == 0) - statusid += mystat.st_ctime; + if (stat((path + "/bincimap-cache").c_str(), &mystat) == 0) statusid += mystat.st_ctime; return statusid; } //------------------------------------------------------------------------ -bool Maildir::getStatus(const string &path, Status &s) const +bool Maildir::getStatus(const string &path, Status &s) const { unsigned int messages = 0; unsigned int unseen = 0; @@ -336,36 +319,22 @@ bool Maildir::getStatus(const string &path, Status &s) const const string cachefilename = path + "/bincimap-cache"; FILE *fp = fopen(cachefilename.c_str(), "r"); - if (fp) do { - char inputBuffer[512]; - if (!fgets(inputBuffer, sizeof(inputBuffer), fp)) { - fclose(fp); - return false; - } + if (fp) do + { + char inputBuffer[512]; + if (!fgets(inputBuffer, sizeof(inputBuffer), fp)) { + fclose(fp); + return false; + } - // terminate the buffer - inputBuffer[sizeof(inputBuffer) - 1] = '\0'; + // terminate the buffer + inputBuffer[sizeof(inputBuffer) - 1] = '\0'; - char cacheFileVersionBuffer[512]; - - if (sscanf(inputBuffer, "%s %u %u", cacheFileVersionBuffer, - &readUidValidity, &readUidNext) != 3 - || strcmp(cacheFileVersionBuffer, BINC_CACHE) != 0) { - fclose(fp); - readUidValidity = 0; - readUidNext = 1; - mincache.clear(); - break; - } + char cacheFileVersionBuffer[512]; - unsigned int readUID; - unsigned int readSize; - unsigned int readInternalDate; - char readUnique[512]; - while (fgets(inputBuffer, sizeof(inputBuffer), fp)) { - inputBuffer[sizeof(inputBuffer) - 1] = '\0'; - if (sscanf(inputBuffer, "%u %u %u %s", &readUID, - &readInternalDate, &readSize, readUnique) != 4) { + if (sscanf(inputBuffer, "%s %u %u", cacheFileVersionBuffer, &readUidValidity, &readUidNext) != 3 + || strcmp(cacheFileVersionBuffer, BINC_CACHE) != 0) + { fclose(fp); readUidValidity = 0; readUidNext = 1; @@ -373,13 +342,29 @@ bool Maildir::getStatus(const string &path, Status &s) const break; } - mincache[readUnique] = true; - } - - fclose(fp); + unsigned int readUID; + unsigned int readSize; + unsigned int readInternalDate; + char readUnique[512]; + while (fgets(inputBuffer, sizeof(inputBuffer), fp)) { + inputBuffer[sizeof(inputBuffer) - 1] = '\0'; + if (sscanf(inputBuffer, "%u %u %u %s", &readUID, &readInternalDate, &readSize, readUnique) != 4) + { + fclose(fp); + readUidValidity = 0; + readUidNext = 1; + mincache.clear(); + break; + } - s.setUidValidity(readUidValidity < 1 ? time(0) : readUidValidity); - } while (0); else { + mincache[readUnique] = true; + } + + fclose(fp); + + s.setUidValidity(readUidValidity < 1 ? time(0) : readUidValidity); + } while (0); + else { s.setUidValidity(time(0)); } @@ -387,12 +372,10 @@ bool Maildir::getStatus(const string &path, Status &s) const DIR *dirp = opendir((path + "/new").c_str()); if (dirp == 0) return false; - struct dirent *direntp; + struct dirent *direntp; while ((direntp = readdir(dirp)) != 0) { const string filename = direntp->d_name; - if (filename[0] == '.' - || filename.find(':') != string::npos - || filename.find('/') != string::npos) + if (filename[0] == '.' || filename.find(':') != string::npos || filename.find('/') != string::npos) continue; ++recent; @@ -404,13 +387,11 @@ bool Maildir::getStatus(const string &path, Status &s) const closedir(dirp); // Scan cur - if ((dirp = opendir((path + "/cur").c_str())) == 0) - return false; + if ((dirp = opendir((path + "/cur").c_str())) == 0) return false; while ((direntp = readdir(dirp)) != 0) { const string dname = direntp->d_name; - if (dname[0] == '.') - continue; + if (dname[0] == '.') continue; ++messages; @@ -423,8 +404,7 @@ bool Maildir::getStatus(const string &path, Status &s) const ++readUidNext; } - if (dname.substr(pos).find('S') == string::npos) - ++unseen; + if (dname.substr(pos).find('S') == string::npos) ++unseen; } else { if (mincache.find(dname) == mincache.end()) { ++recent; @@ -436,7 +416,7 @@ bool Maildir::getStatus(const string &path, Status &s) const } closedir(dirp); - + s.setRecent(recent); s.setMessages(messages); s.setUnseen(unseen); @@ -449,15 +429,13 @@ bool Maildir::getStatus(const string &path, Status &s) const unsigned int Maildir::getMaxUid(void) const { MessageMap::const_iterator i = messages.end(); - if (i == messages.begin()) - return 0; + if (i == messages.begin()) return 0; --i; for (;;) { const MaildirMessage &message = i->second; if (message.isExpunged()) { - if (i == messages.begin()) - return 0; + if (i == messages.begin()) return 0; --i; } else { return message.getUID(); @@ -472,15 +450,13 @@ unsigned int Maildir::getMaxSqnr(void) const { int sqnr = messages.size(); MessageMap::const_iterator i = messages.end(); - if (i == messages.begin()) - return 0; + if (i == messages.begin()) return 0; --i; for (;;) { const MaildirMessage &message = i->second; if (message.isExpunged()) { - if (i == messages.begin()) - return 0; + if (i == messages.begin()) return 0; --sqnr; --i; } else { @@ -539,7 +515,7 @@ bool Maildir::commitNewMessages(const string &mbox) map<MaildirMessage *, string> committedMessages; struct timeval youngestFile = {0, 0}; - + bool abort = false; while (!abort && i != newMessages.end()) { MaildirMessage &m = *i; @@ -560,13 +536,10 @@ bool Maildir::commitNewMessages(const string &mbox) // Generate Maildir conformant file name BincStream ssid; - ssid << (int) tv.tv_sec << "." - << "R" << (int) rand() - << "M" << (int) tv.tv_usec - << "P" << (int) session.getPid() - << "Q" << numDeliveries++ - << "." << session.getEnv("TCPLOCALHOST"); - + ssid << (int)tv.tv_sec << "." + << "R" << (int)rand() << "M" << (int)tv.tv_usec << "P" << (int)session.getPid() << "Q" + << numDeliveries++ << "." << session.getEnv("TCPLOCALHOST"); + BincStream ss; ss << mbox << "/new/" << ssid.str(); @@ -581,12 +554,10 @@ bool Maildir::commitNewMessages(const string &mbox) break; } - if (errno == EEXIST) - continue; + if (errno == EEXIST) continue; - bincWarning << "link(" << toImapString(safeName) << ", " - << toImapString(fileName) << ") failed: " - << strerror(errno) << endl; + bincWarning << "link(" << toImapString(safeName) << ", " << toImapString(fileName) + << ") failed: " << strerror(errno) << endl; session.setResponseCode("TRYCREATE"); session.setLastError("failed, internal error."); @@ -605,24 +576,21 @@ bool Maildir::commitNewMessages(const string &mbox) for (i = newMessages.begin(); i != newMessages.end(); ++i) unlink((*i).getSafeName().c_str()); - map<MaildirMessage *, string>::const_iterator j - = committedMessages.begin(); + map<MaildirMessage *, string>::const_iterator j = committedMessages.begin(); while (j != committedMessages.end()) { if (unlink(j->second.c_str()) != 0) { if (errno == ENOENT) { - // FIXME: The message was probably moves away from new/ by - // another IMAP session. - bincWarning << "error rollbacking after failed commit to " - << toImapString(mbox) << ", failed to unlink " - << toImapString(j->second) - << ": " << strerror(errno) << endl; + // FIXME: The message was probably moves away from new/ by + // another IMAP session. + bincWarning << "error rollbacking after failed commit to " << toImapString(mbox) + << ", failed to unlink " << toImapString(j->second) << ": " << strerror(errno) + << endl; } else { - bincWarning << "error rollbacking after failed commit to " - << toImapString(mbox) << ", failed to unlink " - << toImapString(j->second) - << ": " << strerror(errno) << endl; - newMessages.clear(); - return false; + bincWarning << "error rollbacking after failed commit to " << toImapString(mbox) + << ", failed to unlink " << toImapString(j->second) << ": " << strerror(errno) + << endl; + newMessages.clear(); + return false; } } @@ -639,14 +607,12 @@ bool Maildir::commitNewMessages(const string &mbox) // moving the message into cur. struct timeval tv; gettimeofday(&tv, 0); - while (tv.tv_sec == youngestFile.tv_sec - && tv.tv_usec == youngestFile.tv_usec) { + while (tv.tv_sec == youngestFile.tv_sec && tv.tv_usec == youngestFile.tv_usec) { gettimeofday(&tv, 0); } - map<MaildirMessage *, string>::const_iterator j - = committedMessages.begin(); - for (;j != committedMessages.end(); ++j) { + map<MaildirMessage *, string>::const_iterator j = committedMessages.begin(); + for (; j != committedMessages.end(); ++j) { string basename = j->second.substr(j->second.rfind('/') + 1); int flags = j->first->getStdFlags(); @@ -656,14 +622,12 @@ bool Maildir::commitNewMessages(const string &mbox) if (flags & Message::F_ANSWERED) flagStr += "R"; if (flags & Message::F_SEEN) flagStr += "S"; if (flags & Message::F_DELETED) flagStr += "T"; - + string dest = mbox + "/cur/" + basename + ":2," + flagStr; - if (rename(j->second.c_str(), dest.c_str()) == 0) - continue; + if (rename(j->second.c_str(), dest.c_str()) == 0) continue; if (errno != ENOENT) - bincWarning << "when setting flags on: " << j->second - << ": " << strerror(errno) << endl; + bincWarning << "when setting flags on: " << j->second << ": " << strerror(errno) << endl; } committedMessages.clear(); @@ -684,8 +648,7 @@ bool Maildir::rollBackNewMessages(void) } //------------------------------------------------------------------------ -bool Maildir::fastCopy(Message &m, Mailbox &desttype, - const std::string &destname) +bool Maildir::fastCopy(Message &m, Mailbox &desttype, const std::string &destname) { // At this point, fastCopy is broken because the creation time is // equal for the two clones. The new clone must have a new creation @@ -696,54 +659,44 @@ bool Maildir::fastCopy(Message &m, Mailbox &desttype, Session &session = Session::getInstance(); MaildirMessage *message = dynamic_cast<MaildirMessage *>(&m); - if (!message) - return false; + if (!message) return false; string mfilename = message->getFileName(); - if (mfilename == "") - return false; + if (mfilename == "") return false; Maildir *mailbox = dynamic_cast<Maildir *>(&desttype); - if (!mailbox) - return false; + if (!mailbox) return false; for (int attempt = 0; attempt < 1000; ++attempt) { - struct timeval tv; gettimeofday(&tv, 0); // Generate Maildir conformant file name BincStream ssid; - ssid << (int) tv.tv_sec << "." - << "R" << (int) rand() - << "M" << (int) tv.tv_usec - << "P" << (int) session.getPid() - << "Q" << numDeliveries++ - << "." << session.getEnv("TCPLOCALHOST"); + ssid << (int)tv.tv_sec << "." + << "R" << (int)rand() << "M" << (int)tv.tv_usec << "P" << (int)session.getPid() << "Q" + << numDeliveries++ << "." << session.getEnv("TCPLOCALHOST"); BincStream ss; ss << destname << "/tmp/" << ssid.str(); - + string fileName = ss.str(); - + if (link((path + "/cur/" + mfilename).c_str(), fileName.c_str()) == 0) { MaildirMessage newmess = *message; newmess.setSafeName(fileName); newmess.setUnique(ssid.str()); - newmess.setInternalDate((time_t) tv.tv_sec); + newmess.setInternalDate((time_t)tv.tv_sec); newmess.setUID(0); newMessages.push_back(newmess); break; } - - if (errno == EEXIST) - continue; - - bincWarning << "Warning: link(" - << toImapString(path + "/cur/" + mfilename) - << ", " << toImapString(fileName) << ") failed: " - << strerror(errno) << endl; - + + if (errno == EEXIST) continue; + + bincWarning << "Warning: link(" << toImapString(path + "/cur/" + mfilename) << ", " + << toImapString(fileName) << ") failed: " << strerror(errno) << endl; + session.setResponseCode("TRYCREATE"); session.setLastError("failed, internal error."); return false; @@ -756,12 +709,10 @@ bool Maildir::fastCopy(Message &m, Mailbox &desttype, MaildirMessage *Maildir::get(const std::string &id) { MaildirIndexItem *item = index.find(id); - if (!item) - return 0; + if (!item) return 0; unsigned int uid = item->uid; - if (messages.find(uid) == messages.end()) - return 0; + if (messages.find(uid) == messages.end()) return 0; return &messages.find(uid)->second; } @@ -770,8 +721,7 @@ MaildirMessage *Maildir::get(const std::string &id) void Maildir::add(MaildirMessage &m) { MessageMap::iterator it = messages.find(m.getUID()); - if (it != messages.end()) - messages.erase(it); + if (it != messages.end()) messages.erase(it); messages.insert(make_pair(m.getUID(), m)); index.insert(m.getUnique(), m.getUID()); } @@ -783,8 +733,7 @@ unsigned int MaildirIndex::getSize(void) const } //------------------------------------------------------------------------ -void MaildirIndex::insert(const string &unique, unsigned int uid, - const string &fileName) +void MaildirIndex::insert(const string &unique, unsigned int uid, const string &fileName) { if (idx.find(unique) == idx.end()) { MaildirIndexItem item; @@ -802,16 +751,14 @@ void MaildirIndex::insert(const string &unique, unsigned int uid, void MaildirIndex::remove(const string &unique) { map<string, MaildirIndexItem>::iterator it = idx.find(unique); - if (it != idx.end()) - idx.erase(it); + if (it != idx.end()) idx.erase(it); } //------------------------------------------------------------------------ MaildirIndexItem *MaildirIndex::find(const string &unique) { map<string, MaildirIndexItem>::iterator it = idx.find(unique); - if (it != idx.end()) - return &it->second; + if (it != idx.end()) return &it->second; return 0; } |