Ejemplo n.º 1
0
static gboolean
miner_needs_check (TrackerMiner *miner,
                   gboolean      store_available)
{
	/* Reasons to not mark ourselves as cleanly shutdown include:
	 *
	 * 1. Still crawling or with files to process in our queues.
	 * 2. We crash (out of our control usually anyway).
	 * 3. At least one of the miners is PAUSED, we have
	 *    to exclude the situations where the miner is
	 *    exclusively paused due to the store not being
	 *    available, but the miner is actually done.
	 */
	if (!tracker_miner_is_paused (miner)) {
		if (TRACKER_IS_MINER_FS (miner) &&
		    tracker_miner_fs_has_items_to_process (TRACKER_MINER_FS (miner))) {
			/* There are items left to process */
			return TRUE;
		}

		/* FIXME: We currently don't check the applications
		 *  miner OR the userguides miner if we are finished
		 * before returning TRUE/FALSE here, should we?
		 */

		/* We consider the miner finished */
		return FALSE;
	} else {
		if (store_available) {
			/* Paused for other reasons, so probably not done */
			return TRUE;
		} else {
			/* Check whether there are more pause
			 * reasons than the store being out.
			 */
			return tracker_miner_get_n_pause_reasons (miner) > 1;
		}
	}
}
Ejemplo n.º 2
0
static void
decorator_update_state (TrackerDecorator *decorator,
                        const gchar      *message,
                        gboolean          estimate_time)
{
	TrackerDecoratorPrivate *priv;
	gint remaining_time = -1;
	gdouble progress = 1;
	gsize total_items;

	priv = decorator->priv;
	remaining_time = 0;
	total_items = priv->n_remaining_items + priv->n_processed_items;

	if (priv->n_remaining_items > 0)
		progress = ((gdouble) priv->n_processed_items / total_items);

	if (priv->timer && estimate_time &&
	    !tracker_miner_is_paused (TRACKER_MINER (decorator))) {
		gdouble elapsed;

		/* FIXME: Quite naive calculation */
		elapsed = g_timer_elapsed (priv->timer, NULL);

		if (priv->n_processed_items > 0)
			remaining_time = (priv->n_remaining_items * elapsed) / priv->n_processed_items;
	}

	g_object_set (decorator,
	              "progress", progress,
	              "remaining-time", remaining_time,
	              NULL);

	if (message)
		g_object_set (decorator, "status", message, NULL);
}