summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-11-30 00:43:06 +0100
committerChristian Grothoff <christian@grothoff.org>2019-11-30 00:43:06 +0100
commit35dc96ac784586d0c137a43ff90eea7b7b253d7a (patch)
tree7076cbf5f59d84eaa364f27e6690e11bdd5ee450
parent1aa6d519eb1454dce23232ea9c3f2a6a40618e02 (diff)
downloadsync-35dc96ac784586d0c137a43ff90eea7b7b253d7a.tar.gz
sync-35dc96ac784586d0c137a43ff90eea7b7b253d7a.tar.bz2
sync-35dc96ac784586d0c137a43ff90eea7b7b253d7a.zip
implement -g option in sync-dbinit
-rw-r--r--src/syncdb/sync-dbinit.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/syncdb/sync-dbinit.c b/src/syncdb/sync-dbinit.c
index be78eb8..95aaeb6 100644
--- a/src/syncdb/sync-dbinit.c
+++ b/src/syncdb/sync-dbinit.c
@@ -35,6 +35,11 @@ static int global_ret;
static int reset_db;
/**
+ * -g option: do GC reset
+ */
+static int gc_db;
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -64,6 +69,20 @@ run (void *cls,
SYNC_DB_plugin_unload (plugin);
plugin = SYNC_DB_plugin_load (cfg);
}
+ if (gc_db)
+ {
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Absolute ancient;
+
+ now = GNUNET_TIME_absolute_get ();
+ ancient = GNUNET_TIME_absolute_subtract (now,
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_YEARS,
+ 6));
+ plugin->gc (plugin->cls,
+ now,
+ ancient);
+ }
SYNC_DB_plugin_unload (plugin);
}
@@ -85,6 +104,10 @@ main (int argc,
"reset",
"reset database (DANGEROUS: all existing data is lost!)",
&reset_db),
+ GNUNET_GETOPT_option_flag ('g',
+ "garbagecollect",
+ "remove state data from database",
+ &gc_db),
GNUNET_GETOPT_OPTION_END
};