dovecot-2.0: lib-storage: Fixed accessing uncommitted saved mail...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Jun 4 21:16:49 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/b5d8a7a8695e
changeset: 11481:b5d8a7a8695e
user: Timo Sirainen <tss at iki.fi>
date: Fri Jun 04 19:16:42 2010 +0100
description:
lib-storage: Fixed accessing uncommitted saved mails with dsync
dsync preserves uids, so uid==0 check won't work for detecting such mails.
diffstat:
src/lib-storage/index/cydir/cydir-save.c | 1 +
src/lib-storage/index/dbox-common/dbox-save.c | 1 +
src/lib-storage/index/dbox-multi/mdbox-mail.c | 2 +-
src/lib-storage/index/dbox-multi/mdbox-save.c | 4 +++-
src/lib-storage/index/dbox-single/sdbox-copy.c | 4 +++-
src/lib-storage/index/dbox-single/sdbox-mail.c | 2 +-
src/lib-storage/index/index-mail.c | 1 +
src/lib-storage/index/maildir/maildir-mail.c | 2 +-
src/lib-storage/index/maildir/maildir-save.c | 1 +
src/lib-storage/index/mbox/mbox-save.c | 1 +
src/lib-storage/mail-storage.h | 1 +
11 files changed, 15 insertions(+), 5 deletions(-)
diffs (131 lines):
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/cydir/cydir-save.c
--- a/src/lib-storage/index/cydir/cydir-save.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/cydir/cydir-save.c Fri Jun 04 19:16:42 2010 +0100
@@ -121,6 +121,7 @@
_ctx->dest_mail = ctx->mail;
}
mail_set_seq(_ctx->dest_mail, ctx->seq);
+ _ctx->dest_mail->saving = TRUE;
crlf_input = i_stream_create_crlf(input);
ctx->input = index_mail_cache_parse_init(_ctx->dest_mail, crlf_input);
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/dbox-common/dbox-save.c
--- a/src/lib-storage/index/dbox-common/dbox-save.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/dbox-common/dbox-save.c Fri Jun 04 19:16:42 2010 +0100
@@ -42,6 +42,7 @@
_ctx->dest_mail = ctx->mail;
}
mail_set_seq(_ctx->dest_mail, ctx->seq);
+ _ctx->dest_mail->saving = TRUE;
crlf_input = i_stream_create_lf(input);
ctx->input = index_mail_cache_parse_init(_ctx->dest_mail, crlf_input);
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/dbox-multi/mdbox-mail.c
--- a/src/lib-storage/index/dbox-multi/mdbox-mail.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c Fri Jun 04 19:16:42 2010 +0100
@@ -113,7 +113,7 @@
do {
if (mail->open_file != NULL) {
/* already open */
- } else if (_mail->uid != 0) {
+ } else if (!_mail->saving) {
if (mdbox_mail_lookup(mbox, _mail->transaction->view,
_mail->seq, &map_uid) < 0)
return -1;
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c Fri Jun 04 19:16:42 2010 +0100
@@ -393,7 +393,9 @@
save_mail = array_append_space(&ctx->mails);
save_mail->seq = ctx->ctx.seq;
- if (_ctx->dest_mail != NULL)
+ if (_ctx->dest_mail != NULL) {
mail_set_seq(_ctx->dest_mail, ctx->ctx.seq);
+ _ctx->dest_mail->saving = TRUE;
+ }
return 0;
}
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/dbox-single/sdbox-copy.c
--- a/src/lib-storage/index/dbox-single/sdbox-copy.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/dbox-single/sdbox-copy.c Fri Jun 04 19:16:42 2010 +0100
@@ -51,8 +51,10 @@
dbox_save_add_to_index(ctx);
sdbox_save_add_file(_ctx, dest_file);
- if (_ctx->dest_mail != NULL)
+ if (_ctx->dest_mail != NULL) {
mail_set_seq(_ctx->dest_mail, ctx->seq);
+ _ctx->dest_mail->saving = TRUE;
+ }
return 1;
}
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/dbox-single/sdbox-mail.c
--- a/src/lib-storage/index/dbox-single/sdbox-mail.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/dbox-single/sdbox-mail.c Fri Jun 04 19:16:42 2010 +0100
@@ -32,7 +32,7 @@
if (mail->open_file != NULL) {
/* already set */
return FALSE;
- } else if (_mail->uid != 0) {
+ } else if (!_mail->saving) {
mail->open_file = sdbox_file_init(mbox, _mail->uid);
return FALSE;
} else {
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/index-mail.c Fri Jun 04 19:16:42 2010 +0100
@@ -1172,6 +1172,7 @@
mail->mail.mail.expunged = FALSE;
mail->mail.mail.has_nuls = FALSE;
mail->mail.mail.has_no_nuls = FALSE;
+ mail->mail.mail.saving = FALSE;
}
static void check_envelope(struct index_mail *mail)
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-mail.c Fri Jun 04 19:16:42 2010 +0100
@@ -73,7 +73,7 @@
ctx.path = NULL;
p->stats_open_lookup_count++;
- if (mail->uid != 0) {
+ if (!mail->saving) {
if (maildir_file_do(mbox, mail->uid, do_open, &ctx) < 0)
return NULL;
} else {
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-save.c Fri Jun 04 19:16:42 2010 +0100
@@ -209,6 +209,7 @@
_ctx->dest_mail = ctx->mail;
}
mail_set_seq(_ctx->dest_mail, ctx->seq);
+ _ctx->dest_mail->saving = TRUE;
if (ctx->input == NULL) {
/* FIXME: copying with hardlinking. we could copy the
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/index/mbox/mbox-save.c
--- a/src/lib-storage/index/mbox/mbox-save.c Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/index/mbox/mbox-save.c Fri Jun 04 19:16:42 2010 +0100
@@ -495,6 +495,7 @@
_ctx->dest_mail = ctx->mail;
}
mail_set_seq(_ctx->dest_mail, ctx->seq);
+ _ctx->dest_mail->saving = TRUE;
}
mbox_save_append_flag_headers(ctx->headers, save_flags);
mbox_save_append_keyword_headers(ctx, _ctx->keywords);
diff -r 0602b39ff3ce -r b5d8a7a8695e src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Fri Jun 04 19:14:42 2010 +0100
+++ b/src/lib-storage/mail-storage.h Fri Jun 04 19:16:42 2010 +0100
@@ -251,6 +251,7 @@
uint32_t seq, uid;
unsigned int expunged:1;
+ unsigned int saving:1; /* This mail is still being saved */
unsigned int has_nuls:1; /* message data is known to contain NULs */
unsigned int has_no_nuls:1; /* -''- known to not contain NULs */
More information about the dovecot-cvs
mailing list