summaryrefslogtreecommitdiff
path: root/src/maildir-updateflags.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/maildir-updateflags.cc')
-rw-r--r--src/maildir-updateflags.cc43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/maildir-updateflags.cc b/src/maildir-updateflags.cc
index be37234..a3d2ab7 100644
--- a/src/maildir-updateflags.cc
+++ b/src/maildir-updateflags.cc
@@ -2,16 +2,16 @@
* @file maildir-updateflags.cc
* @brief Implementation of the Maildir class.
* @author Andreas Aardal Hanssen
- * @date 2002-2005
+ * @date 2002-2005
* ----------------------------------------------------------------- **/
+#include "iodevice.h"
+#include "iofactory.h"
#include "maildir.h"
-#include <dirent.h>
-#include <unistd.h>
#include <errno.h>
-#include "iodevice.h"
-#include "iofactory.h"
+#include <dirent.h>
+#include <unistd.h>
using namespace ::std;
@@ -25,18 +25,16 @@ void Binc::Maildir::updateFlags(void)
string curpath = path + "/cur/";
DIR *pdir = opendir(curpath.c_str());
if (pdir == 0) {
- bincError << "failed to open " << curpath << ": "
- << strerror(errno) << endl;
+ bincError << "failed to open " << curpath << ": " << strerror(errno) << endl;
return;
}
// read all entries in the directory
- vector<string> entries;
+ vector<string> entries;
struct dirent *pdirent;
while ((pdirent = readdir(pdir)) != 0) {
string filename = pdirent->d_name;
- if (filename[0] == '.')
- continue;
+ if (filename[0] == '.') continue;
entries.push_back(filename);
}
closedir(pdir);
@@ -55,17 +53,15 @@ void Binc::Maildir::updateFlags(void)
if ((pos = filename.find(":2,")) != string::npos)
uniquename = filename.substr(0, pos);
else
- uniquename = filename;
+ uniquename = filename;
// only update flags for messages that are known.
MaildirMessage *message = get(uniquename);
- if (!message)
- continue;
+ if (!message) continue;
// check if custom flags have changed; if so, we need to regenerate the
// cache file.
- if (message->internalFlags & MaildirMessage::CustomFlagsChanged)
- customFlagsChanged = true;
+ if (message->internalFlags & MaildirMessage::CustomFlagsChanged) customFlagsChanged = true;
// generate the flag string.
string flags;
@@ -81,29 +77,26 @@ void Binc::Maildir::updateFlags(void)
// message.
string srcname = curpath + filename;
string destname = curpath + uniquename + ":2," + flags;
- if (srcname == destname)
- continue;
+ if (srcname == destname) continue;
// rename the file
if (rename(srcname.c_str(), destname.c_str()) != 0) {
if (errno == ENOENT) {
closedir(pdir);
if ((pdir = opendir(curpath.c_str())) == 0) {
- bincError << "failed to open " << curpath << ": "
- << strerror(errno) << endl;
+ bincError << "failed to open " << curpath << ": " << strerror(errno) << endl;
return;
}
- // restart scan. this catches the race condition where concurrent
- // clients may have set a flag or removed the message.
+ // restart scan. this catches the race condition where concurrent
+ // clients may have set a flag or removed the message.
continue;
}
- bincError << "failed to rename " << srcname
- << " to " << destname << ": "
- << strerror(errno) << endl;
+ bincError << "failed to rename " << srcname << " to " << destname << ": " << strerror(errno)
+ << endl;
} else {
- index.insert(uniquename, 0, uniquename + ":2," + flags);
+ index.insert(uniquename, 0, uniquename + ":2," + flags);
}
}