int do_check_integrity(void) { time_t start, stop; GList *lost = NULL; const char *action; gboolean cleanup; long count = 0; if (yes_to_all) { action = "Repairing"; cleanup = TRUE; } else { action = "Checking"; cleanup = FALSE; } qprintf("\n%s DBMAIL message integrity...\n", action); /* This is what we do: 3. Check for loose physmessages 4. Check for loose partlists 5. Check for loose mimeparts */ /* part 3 */ start = stop; qprintf("\n%s DBMAIL physmessage integrity...\n", action); if ((count = db_icheck_physmessages(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected physmessages.\n", count); if (cleanup) { qerrorf("Ok. Orphaned physmessages deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected physmessages.\n", count); } time(&stop); qverbosef("--- %s unconnected physmessages took %g seconds\n", action, difftime(stop, start)); /* end part 3 */ /* part 4 */ start = stop; qprintf("\n%s DBMAIL partlists integrity...\n", action); if ((count = db_icheck_partlists(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected partlists.\n", count); if (cleanup) { qerrorf("Ok. Orphaned partlists deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected partlists.\n", count); } time(&stop); qverbosef("--- %s unconnected partlists took %g seconds\n", action, difftime(stop, start)); /* end part 4 */ /* part 5 */ start = stop; qprintf("\n%s DBMAIL mimeparts integrity...\n", action); if ((count = db_icheck_mimeparts(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected mimeparts.\n", count); if (cleanup) { qerrorf("Ok. Orphaned mimeparts deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected mimeparts.\n", count); } time(&stop); qverbosef("--- %s unconnected mimeparts took %g seconds\n", action, difftime(stop, start)); /* end part 5 */ g_list_destroy(lost); lost = NULL; time(&stop); qverbosef("--- %s block integrity took %g seconds\n", action, difftime(stop, start)); /* end part 6 */ return 0; }
int do_check_integrity(void) { time_t start, stop; GList *lost = NULL; const char *action; gboolean cleanup; long count = 0; if (yes_to_all) { action = "Repairing"; cleanup = TRUE; } else { action = "Checking"; cleanup = FALSE; } qprintf("\n%s DBMAIL message integrity...\n", action); /* This is what we do: 3. Check for loose physmessages 4. Check for loose partlists 5. Check for loose mimeparts 6. Check for loose headernames 7. Check for loose headervalues */ /* part 3 */ time(&start); qprintf("\n%s DBMAIL physmessage integrity...\n", action); if ((count = db_icheck_physmessages(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected physmessages.\n", count); if (cleanup) { qerrorf("Ok. Orphaned physmessages deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected physmessages.\n", count); } time(&stop); qverbosef("--- %s unconnected physmessages took %g seconds\n", action, difftime(stop, start)); /* end part 3 */ /* part 4 */ start = stop; qprintf("\n%s DBMAIL partlists integrity...\n", action); if ((count = db_icheck_partlists(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected partlists.\n", count); if (cleanup) { qerrorf("Ok. Orphaned partlists deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected partlists.\n", count); } time(&stop); qverbosef("--- %s unconnected partlists took %g seconds\n", action, difftime(stop, start)); /* end part 4 */ /* part 5 */ start = stop; qprintf("\n%s DBMAIL mimeparts integrity...\n", action); if ((count = db_icheck_mimeparts(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } if (count > 0) { qerrorf("Ok. Found [%ld] unconnected mimeparts.\n", count); if (cleanup) { qerrorf("Ok. Orphaned mimeparts deleted.\n"); } } else { qprintf("Ok. Found [%ld] unconnected mimeparts.\n", count); } time(&stop); qverbosef("--- %s unconnected mimeparts took %g seconds\n", action, difftime(stop, start)); /* end part 5 */ /* part 6 */ Field_T config; bool cache_readonly = false; config_get_value("header_cache_readonly", "DBMAIL", config); if (strlen(config)) { if (MATCH(config, "true") || MATCH(config, "yes")) { cache_readonly = true; } } if (! cache_readonly) { start = stop; qprintf("\n%s DBMAIL headernames integrity...\n", action); if ((count = db_icheck_headernames(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } qprintf("Ok. Found [%ld] unconnected headernames.\n", count); if (count > 0 && cleanup) { qerrorf("Ok. Orphaned headernames deleted.\n"); } time(&stop); qverbosef("--- %s unconnected headernames took %g seconds\n", action, difftime(stop, start)); } /* end part 6 */ /* part 7 */ start = stop; qprintf("\n%s DBMAIL headervalues integrity...\n", action); if ((count = db_icheck_headervalues(cleanup)) < 0) { qerrorf("Failed. An error occurred. Please check log.\n"); serious_errors = 1; return -1; } qprintf("Ok. Found [%ld] unconnected headervalues.\n", count); if (count > 0 && cleanup) { qerrorf("Ok. Orphaned headervalues deleted.\n"); } time(&stop); qverbosef("--- %s unconnected headervalues took %g seconds\n", action, difftime(stop, start)); /* end part 7 */ g_list_destroy(lost); lost = NULL; time(&stop); qverbosef("--- %s block integrity took %g seconds\n", action, difftime(stop, start)); return 0; }