index->indexid = 0;
}
-int mail_index_mark_corrupted(struct mail_index *index)
+void mail_index_mark_corrupted(struct mail_index *index)
{
struct mail_index_header hdr;
+ mail_index_set_inconsistent(index);
+
if (index->readonly)
- return 0;
+ return;
/* make sure we can write the header */
if (!MAIL_INDEX_MAP_IS_IN_MEMORY(index->map)) {
if (mprotect(index->map->mmap_base, sizeof(hdr),
PROT_READ | PROT_WRITE) < 0) {
mail_index_set_syscall_error(index, "mprotect()");
- return -1;
+ return;
}
}
hdr = *index->hdr;
hdr.flags |= MAIL_INDEX_HDR_FLAG_CORRUPTED;
- if (mail_index_write_header(index, &hdr) < 0)
- return -1;
-
- if (fsync(index->fd) < 0)
- return mail_index_set_syscall_error(index, "fsync()");
-
- mail_index_set_inconsistent(index);
- return 0;
+ if (mail_index_write_header(index, &hdr) == 0) {
+ if (fsync(index->fd) < 0)
+ mail_index_set_syscall_error(index, "fsync()");
+ }
}
int mail_index_set_syscall_error(struct mail_index *index,
int mail_index_sync_end(struct mail_index_sync_ctx *ctx);
/* Mark index file corrupted. Invalidates all views. */
-int mail_index_mark_corrupted(struct mail_index *index);
+void mail_index_mark_corrupted(struct mail_index *index);
/* Check and fix any found problems. If index is broken beyond repair, calls
mail_index_reset() and returns 0. Otherwise returns -1 if there was some
I/O error or 1 if everything went ok. */