diff --git a/commandline.c b/commandline.c index 0a0cf32b..188fb3e9 100644 --- a/commandline.c +++ b/commandline.c @@ -1560,6 +1560,9 @@ int app_rhizome_clean(const struct cli_parsed *parsed, void *context) { if (config.debug.verbose) DEBUG_cli_parsed(parsed); + int verify = cli_arg(parsed, "verify", NULL, NULL, NULL) == 0; + if (verify) + verify_bundles(); struct rhizome_cleanup_report report; if (rhizome_cleanup(&report) == -1) return -1; @@ -2343,7 +2346,7 @@ struct cli_schema command_line_options[]={ "Deliver all new content to the specified Rhizome Direct server. Return when done."}, {app_rhizome_direct_sync,{"rhizome","direct","pull","[]",NULL}, 0, "Fetch all new content from the specified Rhizome Direct server. Return when done."}, - {app_rhizome_clean,{"rhizome","clean",NULL}, 0, + {app_rhizome_clean,{"rhizome","clean","[verify]",NULL}, 0, "Remove stale and orphaned content from the Rhizome store"}, {app_keyring_create,{"keyring","create",NULL}, 0, "Create a new keyring file."}, diff --git a/rhizome.h b/rhizome.h index 7e8f16ac..dbd90b8f 100644 --- a/rhizome.h +++ b/rhizome.h @@ -200,6 +200,7 @@ extern sqlite3 *rhizome_db; int rhizome_opendb(); int rhizome_close_db(); +void verify_bundles(); struct rhizome_cleanup_report { int deleted_stale_incoming_files; diff --git a/rhizome_database.c b/rhizome_database.c index f9f5111b..dd9ef69c 100644 --- a/rhizome_database.c +++ b/rhizome_database.c @@ -160,7 +160,7 @@ void sqlite_log(void *ignored, int result, const char *msg){ WARNF("Sqlite: %d %s", result, msg); } -static void verify_bundles(){ +void verify_bundles(){ // assume that only the manifest itself can be trusted // fetch all manifests and reinsert them. sqlite_retry_state retry = SQLITE_RETRY_STATE_DEFAULT; @@ -187,7 +187,7 @@ static void verify_bundles(){ } if (ret!=0){ DEBUGF("Removing invalid manifest entry @%lld", rowid); - //sqlite_exec_void_retry(&retry, "DELETE FROM MANIFESTS WHERE ROWID=%lld;", rowid); + sqlite_exec_void_retry(&retry, "DELETE FROM MANIFESTS WHERE ROWID=%lld;", rowid); } rhizome_manifest_free(m); }