maildir-sync.c revision 7c424aa51c956c628e3512055841aa2f9eef4833
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "ioloop.h"
#include "hash.h"
#include "maildir-index.h"
#include "mail-index-data.h"
#include "mail-index-util.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <utime.h>
struct mail_index_record *rec,
const char *path, int fname_changed)
{
struct mail_index_update *update;
enum mail_flags flags;
int failed;
return FALSE;
if (fname_changed)
/* update flags after filename has been updated, so it can be
compared correctly */
}
return !failed;
}
struct hash_table *files,
{
struct mail_index_record *rec;
struct mail_index_data_record_header *data_hdr;
unsigned int seq;
int fname_changed;
"Missing location field for record %u",
return FALSE;
}
t_push();
/* get the filename without the ":flags" part */
t_pop();
/* mail is expunged */
return FALSE;
return FALSE;
continue;
}
/* file still exists */
return FALSE;
}
if (check_content_changes) {
"stat()");
return FALSE;
}
rec);
/* file changed. IMAP doesn't allow that, so
we have to treat it as a new message. */
return FALSE;
return FALSE;
continue;
}
}
/* changed - update */
if (fname_changed) {
return FALSE;
}
seq++;
}
return FALSE;
}
return TRUE;
}
struct hash_append_context {
struct mail_index *index;
const char *dir;
int failed;
};
{
t_push();
}
t_pop();
}
struct hash_table *files)
{
struct hash_append_context ctx;
}
{
struct hash_table *files;
struct dirent *d;
unsigned int count;
int failed, check_content_changes;
/* get exclusive lock always, this way the index file's timestamp
is updated even if there's no changes, which is useful to make
sure the cur/ directory isn't scanned all the time when it's
timestamp has changed but hasn't had any other changes. */
return FALSE;
return FALSE;
}
/* we need to find out the new and the deleted files. do this by
first building a hash of what files really exist, then go through
from hash, so finally the hash should contain only the new
files which will be added then. */
if (d->d_name[0] == '.')
continue;
/* hash key is the file name without the ":flags" part */
if (p == d->d_name)
continue;
}
/* Do we want to check changes in file contents? This slows down
things as we need to do extra stat() for all files. */
/* now walk through the index syncing and expunging existing mails */
if (!failed) {
/* then add the new mails */
}
return !failed;
}
int *changes)
{
/* anon-mmaped */
} else {
}
/* cur/ and new/ directories can have new mail - sync the cur/ first
so it'll be a bit bit faster since we haven't yet added the new
mail. */
return FALSE;
}
/* move mail from new/ to cur/ */
return FALSE;
/* set cur/ and new/ directory's timestamp into past to
make sure if someone adds new mail it the new/ dir's
timestamp isn't set to same as cur/ directory's. */
"utime()");
}
"utime()");
}
/* it's possible that new mail came in just after we
scanned the directory. scan the directory again, this will
update the directory's timestamps so at next sync we'll
always check the new/ dir once more, but at least we can be
sure that no mail got lost. */
return FALSE;
}
/* update sync stamp */
/* no changes, we need to update index's timestamp
ourself to get it changed */
}
return TRUE;
}