Nothing else used it.
--HG--
branch : HEAD
#include "buffer.h"
#include "ioloop.h"
#include "istream.h"
-#include "hex-binary.h"
#include "str.h"
#include "message-date.h"
#include "message-part-serialize.h"
struct index_mail_data *data = &mail->data;
struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
string_t *str;
- const void *ext_data;
switch (field) {
case MAIL_FETCH_IMAP_BODY: {
case MAIL_FETCH_UIDL_BACKEND:
case MAIL_FETCH_SEARCH_SCORE:
case MAIL_FETCH_GUID:
- *value_r = "";
- return 0;
case MAIL_FETCH_HEADER_MD5:
- mail_index_lookup_ext(mail->trans->trans_view, data->seq,
- mail->ibox->md5hdr_ext_idx,
- &ext_data, NULL);
- if (ext_data == NULL) {
- *value_r = "";
- return 0;
- }
- *value_r = binary_to_hex(ext_data, 16);
+ *value_r = "";
return 0;
case MAIL_FETCH_MAILBOX_NAME:
*value_r = _mail->box->name;
ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
ibox->commit_log_file_seq = 0;
ibox->index = index_storage_alloc(box->list, name, flags, index_prefix);
- ibox->md5hdr_ext_idx =
- mail_index_ext_register(ibox->index, "header-md5", 0, 16, 1);
if (box->file_create_mode == 0) {
mailbox_list_get_permissions(box->list, name,
struct mail_cache *cache;
struct mail_vfuncs *mail_vfuncs;
- uint32_t md5hdr_ext_idx;
-
struct timeout *notify_to;
struct index_notify_file *notify_files;
struct index_notify_io *notify_ios;
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
+#include "hex-binary.h"
#include "index-mail.h"
#include "mbox-storage.h"
#include "mbox-file.h"
mbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
const char **value_r)
{
-#define EMPTY_MD5_SUM "00000000000000000000000000000000"
+ static uint8_t empty_md5[16] =
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
struct index_mail *mail = (struct index_mail *)_mail;
struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
+ const void *ext_data;
switch (field) {
case MAIL_FETCH_FROM_ENVELOPE:
*value_r = istream_raw_mbox_get_sender(mbox->mbox_stream);
return 0;
case MAIL_FETCH_HEADER_MD5:
- if (index_mail_get_special(_mail, field, value_r) < 0)
- return -1;
- if (**value_r != '\0' && strcmp(*value_r, EMPTY_MD5_SUM) != 0)
+ mail_index_lookup_ext(mail->trans->trans_view, _mail->seq,
+ mbox->md5hdr_ext_idx, &ext_data, NULL);
+ if (ext_data == NULL) {
+ *value_r = "";
+ return 0;
+ }
+ if (memcmp(ext_data, empty_md5, 16) != 0) {
+ *value_r = binary_to_hex(ext_data, 16);
return 0;
+ }
- /* i guess in theory the EMPTY_MD5_SUM is valid and can happen,
+ /* i guess in theory the empty_md5 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_md5_finish(ctx->mbox_md5_ctx, hdr_md5_sum);
mail_index_update_ext(ctx->trans, ctx->seq,
- ctx->mbox->ibox.md5hdr_ext_idx,
+ ctx->mbox->md5hdr_ext_idx,
hdr_md5_sum, NULL);
}
mail_index_ext_register(mbox->ibox.index, "mbox",
sizeof(mbox->mbox_hdr),
sizeof(uint64_t), sizeof(uint64_t));
+ mbox->md5hdr_ext_idx =
+ mail_index_ext_register(mbox->ibox.index, "header-md5",
+ 0, 16, 1);
if ((storage->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
mbox->mbox_save_md5 = TRUE;
struct timeout *keep_lock_to;
bool mbox_writeonly;
- uint32_t mbox_ext_idx;
+ uint32_t mbox_ext_idx, md5hdr_ext_idx;
struct mbox_index_header mbox_hdr;
const struct mailbox_update *sync_hdr_update;
/* match by MD5 sum */
mbox->mbox_save_md5 = TRUE;
- mail_index_lookup_ext(view, seq, mbox->ibox.md5hdr_ext_idx,
- &data, NULL);
+ mail_index_lookup_ext(view, seq, mbox->md5hdr_ext_idx, &data, NULL);
return data == NULL ? 0 :
memcmp(data, ctx.hdr_md5_sum, 16) == 0;
}
rec = mail_index_lookup(sync_ctx->sync_view, sync_ctx->idx_seq);
mail_index_lookup_ext(sync_ctx->sync_view,
sync_ctx->idx_seq,
- sync_ctx->mbox->ibox.md5hdr_ext_idx,
+ sync_ctx->mbox->md5hdr_ext_idx,
&data, NULL);
if (data != NULL && memcmp(data, hdr_md5_sum, 16) == 0)
break;
const void *ext_data;
mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq,
- sync_ctx->mbox->ibox.md5hdr_ext_idx,
- &ext_data, NULL);
+ sync_ctx->mbox->md5hdr_ext_idx, &ext_data, NULL);
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,
+ sync_ctx->mbox->md5hdr_ext_idx,
mail_ctx->hdr_md5_sum, NULL);
}
}
if (sync_ctx->mbox->mbox_save_md5 != 0) {
mail_index_update_ext(sync_ctx->t, sync_ctx->idx_seq,
- sync_ctx->mbox->ibox.md5hdr_ext_idx,
+ sync_ctx->mbox->md5hdr_ext_idx,
mail_ctx->hdr_md5_sum, NULL);
}
} else {