Esempio n. 1
0
static MuError
insert_or_update_maybe (const char* fullpath, const char* mdir,
			time_t filestamp, MuIndexCallbackData *data,
			gboolean *updated)
{
	MuMsg *msg;
	GError *err;

	*updated = FALSE;
	if (!needs_index (data, fullpath, filestamp))
		return MU_OK; /* nothing to do for this one */

	err = NULL;
	msg = mu_msg_new_from_file (fullpath, mdir, &err);
	if ((G_UNLIKELY(!msg)))
		goto errexit;

	/* we got a valid id; scan the message contents as well */
	if (G_UNLIKELY((!mu_store_add_msg (data->_store, msg, &err))))
		goto errexit;

	mu_msg_unref (msg);
	*updated = TRUE;
	return MU_OK;

errexit:
	{
		MuError me;
		me = err ? err->code : MU_ERROR;
		g_clear_error (&err);
		if (msg)
			mu_msg_unref (msg);
		return me;
	}
}
Esempio n. 2
0
static MuError
insert_or_update_maybe (const char *fullpath, const char *mdir,
			time_t filestamp, MuIndexCallbackData *data,
			gboolean *updated)
{
	MuMsg		*msg;
	GError		*err;
	gboolean	 rv;

	*updated = FALSE;
	if (!needs_index (data, fullpath, filestamp))
		return MU_OK; /* nothing to do for this one */

	err = NULL;
	msg = mu_msg_new_from_file (fullpath, mdir, &err);
	if (!msg) {
		if (!err)
			g_warning ("error creating message object: %s",
				   fullpath);
		else {
			g_warning ("%s", err->message);
			g_clear_error (&err);
		}
		/* warn, then simply continue */
		return MU_OK;
	}

	/* we got a valid id; scan the message contents as well */
	rv = mu_store_add_msg (data->_store, msg, &err);
	mu_msg_unref (msg);

	if (!rv) {
		g_warning ("error storing message object: %s",
			   err ? err->message : "cause unknown");
		g_clear_error (&err);
		return MU_ERROR;
	}

 	*updated = TRUE;
	return MU_OK;
}