/*! @brief Reset all databases of a group (anchor, hashtable and archive) * * @param group The group * @param error Pointer to an error struct * @returns TRUE on success, FALSE otherwise * */ osync_bool osync_group_reset(OSyncGroup *group, OSyncError **error) { OSyncDB *db = NULL; GList *m = NULL; char *path = NULL; osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, group, error); osync_assert(group); /* Loop over all members... */ for (m = group->members; m; m = m->next) { OSyncMember *member = m->data; /* flush hashtable */ path = g_strdup_printf("%s%chashtable.db", osync_member_get_configdir(member), G_DIR_SEPARATOR); if (!(db = osync_db_new(error))) goto error_and_free; if (!osync_db_open(db, path, error)) goto error_and_free; osync_db_reset_full(db, error); g_free(path); /* flush anchor db */ path = g_strdup_printf("%s%canchor.db", osync_member_get_configdir(member), G_DIR_SEPARATOR); if (!(db = osync_db_new(error))) goto error_and_free; if (!osync_db_open(db, path, error)) goto error_and_free; osync_db_reset_full(db, error); g_free(path); } path = g_strdup_printf("%s%carchive.db", osync_group_get_configdir(group), G_DIR_SEPARATOR); if (!(db = osync_db_new(error))) goto error_and_free; if (!osync_db_open(db, path, error)) goto error_and_free; osync_db_reset_full(db, error); g_free(path); osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; error_and_free: g_free(path); //error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; }
osync_bool osync_db_reset_full_by_path(const char *path, OSyncError **error) { OSyncDB *db = NULL; osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, path, error); osync_assert(path); if (!osync_db_open(db, path, error)) goto error; if (!osync_db_reset_full(db, error)) goto error; osync_trace(TRACE_EXIT, "%s: TRUE", __func__); return TRUE; error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; }