- fixes
[oweals/gnunet.git] / src / namestore / test_namestore_api.c
index ebd8be3f6ac51259b2e0788894f2559c7b07fd3c..a69f276656e1deac90fcdd1e2b286679bd1e311a 100644 (file)
@@ -142,10 +142,29 @@ void put_cont (void *cls, int32_t success, const char *emsg)
   GNUNET_NAMESTORE_lookup_record (nsh, &zone, name, 0, &name_lookup_proc, 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");