[tracker/make-decorator-errors-public] libtracker-miner, tracker-extract: Don't g_warning() on decorator items we don't process



commit 9dfde8d4587e74a0291084faa1cce9e3bc441552
Author: Martyn Russell <martyn lanedo com>
Date:   Fri Mar 21 11:50:05 2014 +0000

    libtracker-miner, tracker-extract: Don't g_warning() on decorator items we don't process
    
    In normal circumstances, we may get TRACKER_DECORATOR_ERROR_{EMPTY|PAUSED},
    but tracker-extract issues a g_warning(). We want to avoid using a warning for
    these warnings because they're normal and expected operations.

 .../libtracker-miner/libtracker-miner-sections.txt |    2 +
 src/libtracker-miner/tracker-decorator.c           |    6 -----
 src/libtracker-miner/tracker-decorator.h           |   22 ++++++++++++++++++++
 src/tracker-extract/tracker-extract-decorator.c    |   17 +++++++++++++-
 4 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/libtracker-miner-sections.txt 
b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
index 081bb48..ff72bbe 100644
--- a/docs/reference/libtracker-miner/libtracker-miner-sections.txt
+++ b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
@@ -171,8 +171,10 @@ TRACKER_TYPE_THUMBNAILER
 <TITLE>TrackerDecorator</TITLE>
 TrackerDecorator
 TrackerDecoratorClass
+TrackerDecoratorError
 TrackerDecoratorInfo
 tracker_decorator_get_type
+tracker_decorator_error_quark
 tracker_decorator_get_class_names
 tracker_decorator_get_data_source
 tracker_decorator_get_n_items
diff --git a/src/libtracker-miner/tracker-decorator.c b/src/libtracker-miner/tracker-decorator.c
index f4823ae..760eb97 100644
--- a/src/libtracker-miner/tracker-decorator.c
+++ b/src/libtracker-miner/tracker-decorator.c
@@ -94,15 +94,9 @@ enum {
        LAST_SIGNAL
 };
 
-typedef enum {
-       TRACKER_DECORATOR_ERROR_EMPTY,
-       TRACKER_DECORATOR_ERROR_PAUSED
-} TrackerDecoratorError;
-
 static guint signals[LAST_SIGNAL] = { 0 };
 static GInitableIface *parent_initable_iface;
 
-static GQuark tracker_decorator_error_quark         (void);
 static void   tracker_decorator_initable_iface_init (GInitableIface   *iface);
 
 G_DEFINE_QUARK (TrackerDecoratorError, tracker_decorator_error)
diff --git a/src/libtracker-miner/tracker-decorator.h b/src/libtracker-miner/tracker-decorator.h
index c3a38a6..6202b41 100644
--- a/src/libtracker-miner/tracker-decorator.h
+++ b/src/libtracker-miner/tracker-decorator.h
@@ -71,7 +71,29 @@ struct _TrackerDecoratorClass {
        gpointer padding[10];
 };
 
+
+/**
+ * TrackerDecoratorError:
+ * @TRACKER_DECORATOR_ERROR_EMPTY: There is no item to be processed
+ * next. It is entirely possible to have a ::items_available signal
+ * emitted and then have this error when calling
+ * tracker_decorator_next_finish() because the signal may apply to a
+ * class which we're not interested in. For example, a new nmo:Email
+ * might have been added to Tracker, but we might only be interested
+ * in nfo:Document. This case would give this error.
+ * @TRACKER_DECORATOR_ERROR_PAUSED: No work was done or will be done
+ * because the miner is currently paused.
+ *
+ * Possible errors returned when calling tracker_decorator_next_finish().
+ **/
+typedef enum {
+       TRACKER_DECORATOR_ERROR_EMPTY,
+       TRACKER_DECORATOR_ERROR_PAUSED
+} TrackerDecoratorError;
+
+
 GType         tracker_decorator_get_type          (void) G_GNUC_CONST;
+GQuark        tracker_decorator_error_quark       (void);
 
 const gchar * tracker_decorator_get_data_source   (TrackerDecorator     *decorator);
 const gchar** tracker_decorator_get_class_names   (TrackerDecorator     *decorator);
diff --git a/src/tracker-extract/tracker-extract-decorator.c b/src/tracker-extract/tracker-extract-decorator.c
index 9df4aff..9c49d47 100644
--- a/src/tracker-extract/tracker-extract-decorator.c
+++ b/src/tracker-extract/tracker-extract-decorator.c
@@ -235,8 +235,21 @@ decorator_next_item_cb (TrackerDecorator *decorator,
 
        if (!info) {
                priv->n_extracting_files--;
-               g_warning ("Next item could not be retrieved: %s", error->message);
-               g_error_free (error);
+
+               if (error &&
+                   error->domain == tracker_decorator_error_quark ()) {
+                       switch (error->code) {
+                       case TRACKER_DECORATOR_ERROR_EMPTY:
+                               g_message ("Next item does not require 2nd stage metadata extraction (e.g. 
resource may not be a file)");
+                               break;
+                       case TRACKER_DECORATOR_ERROR_PAUSED:
+                               g_message ("Next item is on hold because miner is paused");
+                       }
+               } else if (error) {
+                       g_warning ("Next item could not be processed, %s", error->message);
+               }
+
+               g_clear_error (&error);
                return;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]