blob: a63f3547b2e5f5630c969cf2945409a273b30549 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/**
* @file maildir-expunge.cc
* @brief Implementation of the Maildir class.
* @author Andreas Aardal Hanssen
* @date 2002-2005
*/
#include "iodevice.h"
#include "iofactory.h"
#include "maildir.h"
#include "maildirmessage.h"
#include <errno.h>
#include <unistd.h>
using namespace Binc;
void Maildir::expungeMailbox(void)
{
if (readOnly) return;
Mailbox::iterator i = begin(SequenceSet::all(), SQNR_MODE | INCLUDE_EXPUNGED);
for (bool success = true; success && i != end(); ++i) {
MaildirMessage &message = reinterpret_cast<MaildirMessage &>(*i);
if ((message.getStdFlags() & Message::F_DELETED) == 0) continue;
message.setExpunged();
const std::string &id = message.getUnique();
// The message might be gone already
MaildirIndexItem *item = index.find(id);
if (!item) continue;
std::string fpath = path + "/cur/" + item->fileName;
while (unlink(fpath.c_str()) != 0) {
if (errno != ENOENT) {
bincWarning << "unable to remove " << fpath << ": " << strerror(errno) << std::endl;
break;
}
if (!scanFileNames()) {
success = false;
break;
}
if ((item = index.find(id)))
break;
else
fpath = path + "/cur/" + item->fileName;
}
}
}
|