tracker r2568 - in trunk: . src/libtracker-common



Author: mr
Date: Tue Nov 25 17:19:48 2008
New Revision: 2568
URL: http://svn.gnome.org/viewvc/tracker?rev=2568&view=rev

Log:
	* src/libtracker-common/tracker-thumbnailer.c: Set a flag if the
	prepare function succeeds so we know the service can be contacted.
	If it can't be contacted for some reason, don't keep trying and
	waiting for the timeout for every file the indexer sends us.
	Instead, just return.


Modified:
   trunk/ChangeLog
   trunk/src/libtracker-common/tracker-thumbnailer.c

Modified: trunk/src/libtracker-common/tracker-thumbnailer.c
==============================================================================
--- trunk/src/libtracker-common/tracker-thumbnailer.c	(original)
+++ trunk/src/libtracker-common/tracker-thumbnailer.c	Tue Nov 25 17:19:48 2008
@@ -47,7 +47,21 @@
 
 #define THUMBNAIL_REQUEST_LIMIT 50
 
+typedef struct {
+	GStrv     supported_mime_types;
+
+	gchar    *uris[THUMBNAIL_REQUEST_LIMIT + 1];
+	gchar    *mime_types[THUMBNAIL_REQUEST_LIMIT + 1];
+
+	guint     request_id;
+	guint     timeout_id;
+	guint     count;
 
+	gboolean  service_is_prepared;
+	gboolean  service_is_available;
+} TrackerThumbnailerPrivate;
+
+static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
 
 static DBusGProxy*
 get_thumb_requester (void)
@@ -98,21 +112,6 @@
 	return thumbm_proxy;
 }
 
-typedef struct {
-	GStrv     supported_mime_types;
-
-	gchar    *uris[THUMBNAIL_REQUEST_LIMIT + 1];
-	gchar    *mime_types[THUMBNAIL_REQUEST_LIMIT + 1];
-
-	guint     request_id;
-	guint     count;
-	guint     timeout_id;
-
-	gboolean  service_is_prepared;
-} TrackerThumbnailerPrivate;
-
-static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
-
 static void
 private_free (gpointer data)
 {
@@ -266,13 +265,16 @@
 	if (error) {
 		g_warning ("Thumbnailer service did not return supported mime types, %s",
 			   error->message);
+
 		g_error_free (error);
 	} else if (mime_types) {
 		g_message ("Thumbnailer supports %d mime types", 
 			   g_strv_length (mime_types));
+
 		private->supported_mime_types = mime_types;
-	}
-	
+		private->service_is_available = TRUE;
+	}	
+
 	private->service_is_prepared = TRUE;
 }
 
@@ -314,6 +316,10 @@
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
+	if (!private->service_is_available) {
+		return;
+	}
+
 	if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) {
 		g_debug ("Thumbnailer ignoring mime type:'%s'",
 			 mime_type);
@@ -355,6 +361,10 @@
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
+	if (!private->service_is_available) {
+		return;
+	}
+
 	if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) {
 		g_debug ("Thumbnailer ignoring mime type:'%s' and uri:'%s'",
 			 mime_type,
@@ -389,6 +399,10 @@
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
+	if (!private->service_is_available) {
+		return;
+	}
+
 	private->request_id++;
 
 	g_message ("Requesting thumbnailer cleanup URI:'%s', request_id:%d...",
@@ -407,7 +421,6 @@
 #endif /* THUMBNAILING_OVER_DBUS */
 }
 
-
 void
 tracker_thumbnailer_get_file_thumbnail (const gchar *uri,
 					const gchar *mime_type)
@@ -421,6 +434,10 @@
 	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
+	if (!private->service_is_available) {
+		return;
+	}
+
 	if (!should_be_thumbnailed (private->supported_mime_types, mime_type)) {
 		g_debug ("Thumbnailer ignoring mime type:'%s' and uri:'%s'",
 			 mime_type,



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