mbox-mail.c revision 86c6b2546b0bbfce326583f14d05f59674a6d861
/* Copyright (c) 2003-2012 Dovecot authors, see the included COPYING file */
#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"
#include "mbox-lock.h"
#include "mbox-sync-private.h"
#include "istream-raw-mbox.h"
#include "istream-header-filter.h"
#include <fcntl.h>
#include <unistd.h>
{
struct mbox_transaction_context *t =
t->read_lock_id = 0;
}
}
{
struct mbox_transaction_context *t =
enum mbox_sync_flags sync_flags = 0;
bool deleted;
return -1;
return -1;
}
/* clear the corruption by forcing a full resync */
}
if ((sync_flags & MBOX_SYNC_FORCE_SYNC) != 0) {
/* dirty offsets are broken. make sure we can sync. */
}
i_assert(t->read_lock_id == 0);
return -1;
i_assert(t->read_lock_id != 0);
/* refresh index file after mbox has been locked to
make sure we get only up-to-date mbox offsets. */
return -1;
}
} else if (t->read_lock_id == 0) {
/* file is already locked by another transaction, but
we must keep it locked for the entire transaction,
so increase the lock counter. */
&t->read_lock_id) < 0)
i_unreached();
}
if (mbox_file_open_stream(mbox) < 0)
return -1;
if (ret > 0) {
/* success */
break;
}
if (ret < 0) {
if (deleted)
return -1;
}
/* we'll need to re-sync it completely */
}
if (ret == 0) {
"Losing sync for mail uid=%u in mbox file %s",
}
return 0;
}
{
return 0;
if (mbox_mail_seek(mail) < 0)
return -1;
/* it's broken and conflicts with our "not found"
return value. change it. */
data->received_date = 0;
}
return 0;
}
{
return 0;
/* no way to know this. save the current time into cache and use
that from now on. this works only as long as the index files
are permanent */
return 0;
}
static bool
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
const void *ext_data;
bool expunged;
return TRUE;
}
return TRUE;
} else {
return FALSE;
}
}
static int
const char **value_r)
{
bool move_offset;
switch (field) {
case MAIL_FETCH_FROM_ENVELOPE:
if (mbox_mail_seek(mail) < 0)
return -1;
return 0;
case MAIL_FETCH_GUID:
case MAIL_FETCH_HEADER_MD5:
return 0;
/* 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. */
offset = 0;
move_offset = FALSE;
} else {
move_offset = TRUE;
}
MBOX_SYNC_READONLY) < 0)
return -1;
if (move_offset) {
offset) < 0) {
i_error("mbox %s sync lost during MD5 syncing",
return -1;
}
}
i_error("mbox %s resyncing didn't save header MD5 values",
return -1;
}
return 0;
default:
break;
}
}
static bool
{
struct mail_index_view *view;
const struct mail_index_header *hdr;
int trailer_size;
int ret = 1;
/* we're appending a new message */
return 0;
}
/* We can't really trust trans_view. The next message may already be
expunged from it. Also hdr.messages_count may be incorrect there.
So refresh the index to get the latest changes and get the next
message's offset using a new view. */
if (mbox_sync_header_refresh(mbox) < 0)
return -1;
i_panic("Message unexpectedly expunged from index");
next_offset_r) <= 0)
ret = -1;
/* opened the mailbox as input stream. we can't trust the
sync_size, since it's wrong with compressed mailboxes */
ret = 0;
} else {
/* last message, use the synced mbox size */
}
return ret;
}
{
struct message_size hdr_size;
return 0;
/* we want to return the header size as seen by mail_get_stream(). */
return -1;
/* our header size varies, so don't do any caching */
"Couldn't get mbox size");
return -1;
}
/* use the next message's offset to avoid reading through the entire
message body to find out its size */
else
/* verify that the calculated body size is correct */
return 0;
}
{
struct istream *raw_stream;
int ret;
if (mbox_mail_seek(mail) < 0)
return -1;
if (ret < 0) {
if (mbox_mail_seek(mail) < 0)
return -1;
if (ret < 0) {
i_warning("mbox %s: Can't find next message offset "
}
}
*null_header_filter_callback, (void *)NULL);
return 0;
}
struct message_size *hdr_size,
struct message_size *body_size,
{
if (mbox_mail_init_stream(mail) < 0)
return -1;
}
}
{
}
{
bool ret;
return ret;
}
struct mail_vfuncs mbox_mail_vfuncs = {
NULL,
};