# HG changeset patch # User Timo Sirainen # Date 1030567897 -10800 # Node ID 2876947b8d38e77d0969d48398e84d68de8ca2df # Parent d1407cb2b39bb92d3b10a77ca2faf3cf9f3441a3 more fixes diff -r d1407cb2b39b -r 2876947b8d38 src/lib-index/mbox/mbox-append.c --- 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)) { diff -r d1407cb2b39b -r 2876947b8d38 src/lib-index/mbox/mbox-sync.c --- 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 {