Andreas Aardal Hanssen wrote:
The only safe approach to COPY/APPEND with flags is to store the messages in new/ with no flags, then move the messages to cur/ with flags after one whole second has passed. I'm looking into this solution now.
what do you think about the attached new patch? i am sure that this must be much better than previous one... though...
-- Hiroshima
--- operator-copy.cc.orig Thu Apr 10 06:06:12 2003
+++ operator-copy.cc Mon Jun 2 18:06:55 2003
@@ -92,2 +92,2 @@
else
mode = Mailbox::SQNR_MODE;
+ typedef std::pair<string,int> copiedfile;
+ std::vector<copiedfile> copiedfiles;
+
Mailbox::iterator i = mailbox->begin(command.bset,
Mailbox::SKIP_EXPUNGED|mode);
Mailbox::iterator e = mailbox->end();
@@ -242,5 +245,26 @@
logger << "COPY warning: couldn't unlink " << (char*)safename
<< ": " << strerror(errno) << endl;
delete safename;
+
+ copiedfiles.push_back(copiedfile(filename,message.getStdFlags()));
+ }
+
+ for (vector<copiedfile>::iterator p = copiedfiles.begin(); p != copiedfiles.end();
++p) {
+ string info = ":2,";
+ if (p->second & Message::F_DRAFT) info += "D";
+ if (p->second & Message::F_FLAGGED) info += "F";
+ if (p->second & Message::F_ANSWERED) info += "R";
+ if (p->second & Message::F_SEEN) info += "S";
+ if (p->second & Message::F_DELETED) info += "T";
+
+ string name = p->first + info;
+ name.replace(name.find("/new/"),5,"/cur/",5);
+
+ if (link(p->first.c_str(), name.c_str()) != 0)
+ logger << "warning: link(" << p->first << ", " << name << ") == "
+ << errno << ": " << strerror(errno) << endl;
+ else if (unlink(p->first.c_str()) != 0)
+ logger << "warning: unlink(" << name << ") == "
+ << errno << ": " << strerror(errno) << endl;
}
}

