[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-mail.c, 1.27,
1.28 mbox-sync.c, 1.163, 1.164
cras at dovecot.org
cras at dovecot.org
Thu Jun 16 12:02:02 EEST 2005
- Previous message: [dovecot-cvs] dovecot/src/auth auth-request-handler.c, 1.6,
1.7 auth-request.c, 1.25, 1.26 auth-worker-client.c, 1.12,
1.13 passdb-blocking.c, 1.4, 1.5
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-sync-update.c, 1.7,
1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv2938/lib-storage/index/mbox
Modified Files:
mbox-mail.c mbox-sync.c
Log Message:
When syncing mbox, update MD5 sum for mail if it changes. If we need MD5
sum but it's zero, resync mbox to get it.
Index: mbox-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-mail.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mbox-mail.c 26 Apr 2005 14:52:02 -0000 1.27
+++ mbox-mail.c 16 Jun 2005 09:01:59 -0000 1.28
@@ -14,6 +14,21 @@
#include <unistd.h>
#include <sys/stat.h>
+static void mbox_prepare_resync(struct index_mail *mail)
+{
+ struct mbox_transaction_context *t =
+ (struct mbox_transaction_context *)mail->trans;
+ struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+
+ if (mbox->mbox_lock_type == F_RDLCK) {
+ if (mbox->mbox_lock_id == t->mbox_lock_id)
+ t->mbox_lock_id = 0;
+ (void)mbox_unlock(mbox, mbox->mbox_lock_id);
+ mbox->mbox_lock_id = 0;
+ i_assert(mbox->mbox_lock_type == F_UNLCK);
+ }
+}
+
static int mbox_mail_seek(struct index_mail *mail)
{
struct mbox_transaction_context *t =
@@ -57,14 +72,7 @@
if (ret == 0) {
/* we'll need to re-sync it completely */
- if (mbox->mbox_lock_type == F_RDLCK) {
- if (mbox->mbox_lock_id == t->mbox_lock_id)
- t->mbox_lock_id = 0;
- (void)mbox_unlock(mbox, mbox->mbox_lock_id);
- mbox->mbox_lock_id = 0;
- i_assert(mbox->mbox_lock_type == F_UNLCK);
- }
-
+ mbox_prepare_resync(mail);
sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC;
goto __again;
}
@@ -101,15 +109,32 @@
static const char *
mbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field)
{
+#define EMPTY_MD5_SUM "00000000000000000000000000000000"
struct index_mail *mail = (struct index_mail *)_mail;
struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+ const char *value;
- if (field == MAIL_FETCH_FROM_ENVELOPE) {
+ switch (field) {
+ case MAIL_FETCH_FROM_ENVELOPE:
if (mbox_mail_seek(mail) <= 0)
return NULL;
return istream_raw_mbox_get_sender(mbox->mbox_stream);
+ case MAIL_FETCH_HEADER_MD5:
+ value = index_mail_get_special(_mail, field);
+ if (value != NULL && strcmp(value, EMPTY_MD5_SUM) != 0)
+ return value;
+ /* i guess in theory the EMPTY_MD5_SUM is valid and can happen,
+ but it's almost guaranteed that it means the MD5 sum is
+ missing. recalculate it. */
+ mbox->mbox_save_md5 = TRUE;
+ mbox_prepare_resync(mail);
+ if (mbox_sync(mbox, MBOX_SYNC_FORCE_SYNC) < 0)
+ return NULL;
+ break;
+ default:
+ break;
}
return index_mail_get_special(_mail, field);
Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- mbox-sync.c 14 Jun 2005 21:42:02 -0000 1.163
+++ mbox-sync.c 16 Jun 2005 09:01:59 -0000 1.164
@@ -371,6 +371,28 @@
mail_index_keywords_free(keywords);
}
+static int
+mbox_sync_update_md5_if_changed(struct mbox_sync_mail_context *mail_ctx)
+{
+ struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+ const void *ext_data;
+
+ if (mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq,
+ sync_ctx->mbox->ibox.md5hdr_ext_idx,
+ &ext_data) < 0) {
+ mail_storage_set_index_error(&sync_ctx->mbox->ibox);
+ return -1;
+ }
+
+ if (ext_data == NULL ||
+ memcmp(mail_ctx->hdr_md5_sum, ext_data, 16) != 0) {
+ mail_index_update_ext(sync_ctx->t, sync_ctx->idx_seq,
+ sync_ctx->mbox->ibox.md5hdr_ext_idx,
+ mail_ctx->hdr_md5_sum, NULL);
+ }
+ return 0;
+}
+
static int mbox_sync_update_index(struct mbox_sync_mail_context *mail_ctx,
const struct mail_index_record *rec)
{
@@ -465,6 +487,12 @@
!array_cmp(&idx_mail.keywords, &mail_ctx->mail.keywords))
mbox_sync_update_index_keywords(mail_ctx);
t_pop();
+
+ /* see if we need to update md5 sum. */
+ if (sync_ctx->mbox->mbox_save_md5 != 0) {
+ if (mbox_sync_update_md5_if_changed(mail_ctx) < 0)
+ return -1;
+ }
}
if (mail_ctx->recent &&
- Previous message: [dovecot-cvs] dovecot/src/auth auth-request-handler.c, 1.6,
1.7 auth-request.c, 1.25, 1.26 auth-worker-client.c, 1.12,
1.13 passdb-blocking.c, 1.4, 1.5
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-sync-update.c, 1.7,
1.8
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list