Mercurial > dovecot > original-hg > dovecot-1.2
changeset 80:2876947b8d38 HEAD
more fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 28 Aug 2002 23:51:37 +0300 |
parents | d1407cb2b39b |
children | 1dfa3c9d60ef |
files | src/lib-index/mbox/mbox-append.c src/lib-index/mbox/mbox-sync.c |
diffstat | 2 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mbox/mbox-append.c Wed Aug 28 23:32:56 2002 +0300 +++ b/src/lib-index/mbox/mbox-append.c Wed Aug 28 23:51:37 2002 +0300 @@ -190,7 +190,7 @@ return FALSE; for (;;) { - if (inbuf->offset != 0) { + if (inbuf->start_offset + inbuf->offset != 0) { /* we're at the [\r]\n before the From-line, skip it */ if (!mbox_skip_crlf(inbuf)) {
--- a/src/lib-index/mbox/mbox-sync.c Wed Aug 28 23:32:56 2002 +0300 +++ b/src/lib-index/mbox/mbox-sync.c Wed Aug 28 23:51:37 2002 +0300 @@ -114,6 +114,7 @@ int mbox_index_sync(MailIndex *index) { struct stat st; + uoff_t filesize; i_assert(index->lock_type != MAIL_LOCK_SHARED); @@ -126,11 +127,21 @@ if (index->file_sync_stamp == st.st_mtime) return TRUE; - if (index->mbox_size == 0 && st.st_size != 0) + filesize = st.st_size; + if (index->mbox_size == 0 && filesize != 0) { index->mbox_size = get_indexed_mbox_size(index); - if (index->file_sync_stamp == 0 && - index->mbox_size == (uoff_t)st.st_size) { + /* problem .. index->mbox_size points to data after the last + message. that should be \n, \r\n, or end of file. modify + filesize accordingly to allow any of the extra 0-2 bytes. + Don't actually bother to open the file and verify it, it'd + just slow things.. */ + if (filesize == index->mbox_size+1 || + filesize == index->mbox_size+2) + filesize = index->mbox_size; + } + + if (index->file_sync_stamp == 0 && index->mbox_size == filesize) { /* just opened the mailbox, and the file size is same as we expected. don't bother checking it any further. */ index->file_sync_stamp = st.st_mtime; @@ -140,7 +151,7 @@ index->file_sync_stamp = st.st_mtime; /* file has been modified. */ - if (index->mbox_size < (uoff_t)st.st_size) { + if (index->mbox_size < filesize) { /* file was grown, hopefully just new mail */ return mbox_check_new_mail(index); } else {