[tpop3d-discuss] [PATCH] Lots of 'Index exists, but has some
stale or corrupt data' messages
Martin Blapp
mb at imp.ch
Fri, 11 Feb 2005 00:32:50 +0100 (CET)
There is no need to do a addition stat.
> There is still a bug, truncate(indexfile,sizeof(index_signature)) should
> be truncate(indexfile,sizeof(index_signature)-1)
>
> > +
> > + /* Check for empty mail boxes and kill a stale indexfile */
> > + if ((stat(m->name, &sb) == 0) && (sb.st_size == 0))
> > + truncate(indexfile,sizeof(index_signature)-1);
--- mailspool.c Thu Feb 10 18:17:21 2005
+++ mailspool.c Thu Feb 10 18:17:05 2005
@@ -740,6 +740,17 @@
goto fail;
}
+ /* Check for stale indexfiles on empty mailboxes */
+ if (m->st.st_size == 0) {
+ if (st.st_size > sizeof(index_signature)-1)
+ truncate(indexfile,sizeof(index_signature)-1);
+
+ if (fp) fclose(fp);
+
+ if (indexfile) xfree(indexfile);
+ return 0;
+ }
+
/* OK, found an index file; let's try loading some data out of it. */
if (fread(sigbuf, 1, sizeof(sigbuf) - 1, fp) != sizeof(sigbuf) - 1 ||
memcmp(sigbuf, index_signature, sizeof(sigbuf) - 1) != 0) {
log_print(LOG_WARNING, _("mailspool_load_index(%s): index exists, but
is of wrong format; ignoring"), indexfile);