Exemplo n.º 1
0
static MuQuery*
get_query_obj (MuStore *store, GError **err)
{
	MuQuery *mquery;
	unsigned count;

	count = mu_store_count (store, err);

	if (count == (unsigned)-1)
		return NULL;

	if (count == 0) {
		g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_XAPIAN_IS_EMPTY,
			     "the database is empty");
		return NULL;
	}

	if (!mu_store_versions_match (store)) {
		g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_XAPIAN_VERSION_MISMATCH,
			     "the database needs a rebuild");
		return NULL;
	}

	mquery = mu_query_new (store, err);
	if (!mquery)
		return NULL;

	return mquery;
}
Exemplo n.º 2
0
Arquivo: mu-index.c Projeto: Dabg/mu
MuIndex*
mu_index_new (MuStore *store, GError **err)
{
	MuIndex *index;
	unsigned count;

	g_return_val_if_fail (store, NULL);
	g_return_val_if_fail (!mu_store_is_read_only(store), NULL);

	index = g_new0 (MuIndex, 1);

	index->_store = mu_store_ref (store);

	/* set the default max file size */
	index->_max_filesize = MU_INDEX_MAX_FILE_SIZE;

	count = mu_store_count (store, err);
	if (count == (unsigned)-1)
		return NULL;
	else if (count  == 0)
		index->_needs_reindex = FALSE;

	/* FIXME */
	/* else */
	/* 	index->_needs_reindex = */
	/* 		mu_store_database_needs_upgrade (xpath); */

	return index;
}
Exemplo n.º 3
0
static MuQuery*
get_query_obj (MuStore *store, GError **err)
{
	MuQuery *mquery;
	unsigned count;

	count = mu_store_count (store, err);

	if (count == (unsigned)-1)
		return NULL;

	if (count == 0) {
		g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_XAPIAN_IS_EMPTY,
			     "the database is empty");
		return NULL;
	}

	if (mu_store_needs_upgrade (store)) {
		g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
			     "the database is not up-to-date");
		return NULL;
	}

	mquery = mu_query_new (store, err);
	if (!mquery)
		return NULL;

	return mquery;
}
Exemplo n.º 4
0
/* 'ping' takes no parameters, and provides information about this mu
 * server using a (:pong ...) message (details: see code below)
 */
static MuError
cmd_ping (ServerContext *ctx, GSList *args, GError **err)
{
	unsigned doccount;
	doccount = mu_store_count (ctx->store, err);

	if (doccount == (unsigned)-1)
		return print_and_clear_g_error (err);

	print_expr ("(:pong \"" PACKAGE_NAME "\" "
		    " :props ("
#ifdef BUILD_CRYPTO
		    "  :crypto t "
#endif /*BUILD_CRYPTO*/
		    "  :version \"" VERSION "\" "
		    "  :doccount %u))",doccount);

	return MU_OK;
}
Exemplo n.º 5
0
/* 'ping' takes no parameters, and provides information about this mu
 * server using a (:pong ...) message (details: see code below)
 */
static MuError
cmd_ping (ServerContext *ctx, GSList *args, GError **err)
{
	unsigned doccount;
	doccount = mu_store_count (ctx->store, err);

	if (doccount == (unsigned)-1)
		return print_and_clear_g_error (err);

	print_expr ("(:pong \"" PACKAGE_NAME "\" "
		    " :props (:crypto %s :guile %s "
		    "  :version \"" VERSION "\" "
		    "  :doccount %u))",
		    mu_util_supports (MU_FEATURE_CRYPTO) ? "t" : "nil",
		    mu_util_supports (MU_FEATURE_GUILE|MU_FEATURE_GNUPLOT)
		    ? "t" : "nil",
		    doccount);

	return MU_OK;
}