maildir-sync.c revision c7effa4ad7a053438e5d1d10ba7286c05fb7941b
/* 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>
const char *path,
int fname_changed, int file_changed)
{
return FALSE;
if (fname_changed)
if (file_changed) {
/* file itself changed - reload the header */
if (fd == -1) {
} else {
"close()");
}
}
}
/* update flags after filename has been updated, so it can be
compared correctly */
}
return !failed;
}
{
char str[1024], *p;
unsigned int seq;
int fname_changed, file_changed;
"Missing location field for record %u",
return FALSE;
}
/* get the filename without the ":flags" part */
if (p != NULL) *p = '\0';
/* mail is expunged */
return FALSE;
return FALSE;
continue;
}
/* file still exists */
if (!check_content_changes)
else {
"stat()");
return FALSE;
}
rec);
}
/* changed - update */
if (fname_changed || file_changed) {
return FALSE;
}
seq++;
}
}
return TRUE;
}
typedef struct {
const char *dir;
int failed;
{
}
}
{
}
{
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;
}