- fixes
[oweals/gnunet.git] / src / namestore / test_namestore_api_zone_iteration.c
index c0ef8c809565450fee0d574db4962ffc6e6c7643..95755ceee3d79c7492a70ae576c5e915bccdaf84 100644 (file)
@@ -153,10 +153,29 @@ void zone_proc (void *cls,
   stopiteration_task = GNUNET_SCHEDULER_add_now (&stop_iteration, NULL);
 }
 
+void
+delete_existing_db (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  char *afsdir;
+
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_filename (cfg, "namestore-sqlite",
+                                               "FILENAME", &afsdir))
+  {
+    if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+      if (GNUNET_OK == GNUNET_DISK_file_test (afsdir))
+        if (GNUNET_OK == GNUNET_DISK_directory_remove(afsdir))
+          GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deleted existing database `%s' \n", afsdir);
+   GNUNET_free (afsdir);
+  }
+
+}
+
 static void
 run (void *cls, char *const *args, const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
+  delete_existing_db(cfg);
   endbadly_task = GNUNET_SCHEDULER_add_delayed(TIMEOUT,&endbadly, NULL);
 
   privkey = GNUNET_CRYPTO_rsa_key_create_from_file("hostkey");