dovecot-1.1: If we lose a maildir filename, make sure the messag...
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 6 02:52:55 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/b776f2b8d827
changeset: 7507:b776f2b8d827
user: Timo Sirainen <tss at iki.fi>
date: Tue May 06 02:52:51 2008 +0300
description:
If we lose a maildir filename, make sure the message gets marked as expunged
in index.
diffstat:
1 file changed, 25 insertions(+), 5 deletions(-)
src/lib-storage/index/maildir/maildir-mail.c | 30 +++++++++++++++++++++-----
diffs (49 lines):
diff -r 118ae423dbc4 -r b776f2b8d827 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Tue May 06 01:27:23 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c Tue May 06 02:52:51 2008 +0300
@@ -6,6 +6,7 @@
#include "maildir-storage.h"
#include "maildir-filename.h"
#include "maildir-uidlist.h"
+#include "maildir-sync.h"
#include <stdlib.h>
#include <fcntl.h>
@@ -143,13 +144,32 @@ maildir_mail_get_fname(struct maildir_ma
const char **fname_r)
{
enum maildir_uidlist_rec_flag flags;
+ struct mail_index_view *view;
+ uint32_t seq;
+ bool exists;
*fname_r = maildir_uidlist_lookup(mbox->uidlist, mail->uid, &flags);
- if (*fname_r == NULL) {
- mail_set_expunged(mail);
- return FALSE;
- }
- return TRUE;
+ if (*fname_r != NULL)
+ return TRUE;
+
+ /* file exists in index file, but not in dovecot-uidlist anymore. */
+ mail_set_expunged(mail);
+
+ /* one reason this could happen is if we delayed opening
+ dovecot-uidlist and we're trying to open a mail that got recently
+ expunged. Let's test this theory first: */
+ (void)mail_index_refresh(mbox->ibox.index);
+ view = mail_index_view_open(mbox->ibox.index);
+ exists = mail_index_lookup_seq(view, mail->uid, &seq);
+ mail_index_view_close(&view);
+
+ if (exists) {
+ /* the message still exists in index. this means there's some
+ kind of a desync, which doesn't get fixed if cur/ mtime is
+ the same as in index. fix this by forcing a resync. */
+ (void)maildir_storage_sync_force(mbox, mail->uid);
+ }
+ return FALSE;
}
static int maildir_get_pop3_state(struct index_mail *mail)
More information about the dovecot-cvs
mailing list