mbox-sync.c revision 85eee5da111b2d6260f446bce3fba529e4294c3c
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "mbox-index.h"
#include "mbox-lock.h"
#include "mail-index-util.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
{
return 0;
}
/* get the last record */
offset = 0;
/* get the offset + size of last message, which tells the
last known mbox file size */
}
/* too large to fit in off_t */
return 0;
}
return offset;
}
{
/* anon-mmaped */
} else {
}
/* mbox file was overwritten, close it if it was open */
}
if (lock_type == MAIL_LOCK_EXCLUSIVE) {
/* if we know that we want exclusive lock, we might get
it immediately to save extra lock changes */
return FALSE;
}
/* problem .. index->mbox_size points to data after the last
message. that should be \n or end of file. modify filesize
accordingly to allow the extra byte. Don't actually bother
to open the file and verify it, it'd just slow things.. */
if (index->file_sync_stamp == 0 &&
/* just opened the mailbox, and the file size is same
as we expected. don't bother checking it any
further. */
} else {
/* file has changed, scan through the whole mbox */
if (!mbox_sync_full(index)) {
return FALSE;
}
if (lock_type == MAIL_LOCK_EXCLUSIVE &&
/* mbox_sync_full() left it */
if (!mbox_unlock(index))
return FALSE;
}
}
}
return FALSE;
if (lock_type != MAIL_LOCK_UNLOCK) {
return FALSE;
} else {
if (!mbox_unlock(index))
return FALSE;
}
return TRUE;
}