mail-cache-compress.c revision 13c6532dc104d23061e6901783ceb1ff8872c206
/* Copyright (C) 2003-2004 Timo Sirainen */
#include "lib.h"
#include "buffer.h"
#include "ostream.h"
#include "file-dotlock.h"
#include "file-cache.h"
#include "file-set-size.h"
#include "mail-cache-private.h"
struct mail_cache_copy_context {
int new_msg;
};
{
void *buf_data;
unsigned int i, buf_data_size;
if (buf_data_size == (unsigned int)-1) {
}
/* @UNSAFE: found it, do the merging */
for (i = 0; i < buf_data_size; i++)
break;
}
}
}
static int
{
struct mail_cache_field *cache_field;
enum mail_cache_decision_type dec;
/* duplicate */
}
return 1;
}
if (dec == MAIL_CACHE_DECISION_NO)
return 1;
} else {
if (dec != MAIL_CACHE_DECISION_YES)
return 1;
}
}
if ((data_size & 3) != 0)
return 1;
}
static uint32_t
{
const struct mail_index_ext *ext;
}
static int
{
struct mail_cache_copy_context ctx;
struct mail_cache_view *cache_view;
struct mail_index_transaction *t;
const struct mail_index_header *idx_hdr;
struct mail_cache_header hdr;
struct mail_cache_record cache_rec;
/* get sequence of first message which doesn't need it's temp fields
removed. */
first_new_seq = 1;
} else {
&message_count) < 0)
return -1;
if (first_new_seq == 0)
}
ctx.field_seen_value = 0;
if (++ctx.field_seen_value == 0) {
}
continue;
&old_offset);
}
if (cache->fields_count != 0) {
/* we wrote everything using our internal field ids. so we want
mail_cache_header_fields_get() to use them and ignore any
existing id mappings in the old cache file. */
cache->file_fields_count = 0;
for (i = 0; i < cache->fields_count; i++)
t_push();
t_pop();
}
o_stream_seek(output, 0);
if (o_stream_flush(output) < 0) {
(void)mail_index_transaction_rollback(t);
return -1;
}
/* grow the file some more. doesn't matter if it fails */
}
(void)mail_index_transaction_rollback(t);
return -1;
}
}
struct mail_index_view *view)
{
int fd;
/* get the latest info on fields */
if (mail_cache_header_fields_read(cache) < 0)
return -1;
#ifdef DEBUG
#endif
0, &dotlock);
if (fd == -1) {
return -1;
}
return -1;
}
// FIXME: check that cache file wasn't just recreated
(void)file_dotlock_delete(&dotlock);
return -1;
}
if (file_dotlock_replace(&dotlock,
"file_dotlock_replace()");
return -1;
}
if (mail_cache_map(cache, 0, 0) < 0)
return -1;
if (mail_cache_header_fields_read(cache) < 0)
return -1;
return 0;
}
{
int ret;
/* we're using dotlocking, cache file creation itself creates
the dotlock file we need. */
}
switch (mail_cache_lock(cache)) {
case -1:
return -1;
case 0:
/* couldn't lock, either it's broken or doesn't exist.
just start creating it. */
default:
/* locking succeeded. */
return ret;
}
}
{
return cache->need_compress;
}