tracker r2710 - in branches/turtle: . po src/libtracker-common src/tracker-extract src/trackerd tests/libtracker-common



Author: pvanhoof
Date: Tue Dec 16 14:32:11 2008
New Revision: 2710
URL: http://svn.gnome.org/viewvc/tracker?rev=2710&view=rev

Log:
Merged with trunk

Modified:
   branches/turtle/ChangeLog
   branches/turtle/po/ChangeLog
   branches/turtle/po/es.po
   branches/turtle/src/libtracker-common/tracker-config.c
   branches/turtle/src/libtracker-common/tracker-file-utils.c
   branches/turtle/src/libtracker-common/tracker-file-utils.h
   branches/turtle/src/libtracker-common/tracker-thumbnailer.c
   branches/turtle/src/tracker-extract/tracker-albumart.c
   branches/turtle/src/trackerd/tracker-crawler.c
   branches/turtle/tests/libtracker-common/tracker-file-utils-test.c

Modified: branches/turtle/src/libtracker-common/tracker-config.c
==============================================================================
--- branches/turtle/src/libtracker-common/tracker-config.c	(original)
+++ branches/turtle/src/libtracker-common/tracker-config.c	Tue Dec 16 14:32:11 2008
@@ -1086,13 +1086,13 @@
 	l = config_string_list_to_gslist ((const gchar **) value, is_directory_list);
 
 	if (strcmp (property, "watch-directory-roots") == 0) {
-		priv->watch_directory_roots = tracker_path_list_filter_duplicates (l); 
+		priv->watch_directory_roots = tracker_path_list_filter_duplicates (l, "."); 
 	}
 	else if (strcmp (property, "crawl-directory-roots") == 0) {
-		priv->crawl_directory_roots = tracker_path_list_filter_duplicates (l);
+		priv->crawl_directory_roots = tracker_path_list_filter_duplicates (l, ".");
 	}
 	else if (strcmp (property, "no-watch-directory-roots") == 0) {
-		priv->no_watch_directory_roots = tracker_path_list_filter_duplicates (l);
+		priv->no_watch_directory_roots = tracker_path_list_filter_duplicates (l, ".");
 	}
 	else if (strcmp (property, "no-index-file-types") == 0) {
 		priv->no_index_file_types = l;
@@ -2298,7 +2298,7 @@
 
 	l = priv->watch_directory_roots;
 	priv->watch_directory_roots =
-		tracker_path_list_filter_duplicates (priv->watch_directory_roots);
+		tracker_path_list_filter_duplicates (priv->watch_directory_roots, ".");
 
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);
@@ -2334,7 +2334,7 @@
 
 	l = priv->crawl_directory_roots;
 	priv->crawl_directory_roots =
-		tracker_path_list_filter_duplicates (priv->crawl_directory_roots);
+		tracker_path_list_filter_duplicates (priv->crawl_directory_roots, ".");
 
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);
@@ -2370,7 +2370,7 @@
 
 	l = priv->no_watch_directory_roots;
 	priv->no_watch_directory_roots =
-		tracker_path_list_filter_duplicates (priv->no_watch_directory_roots);
+		tracker_path_list_filter_duplicates (priv->no_watch_directory_roots, ".");
 
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);

Modified: branches/turtle/src/libtracker-common/tracker-file-utils.c
==============================================================================
--- branches/turtle/src/libtracker-common/tracker-file-utils.c	(original)
+++ branches/turtle/src/libtracker-common/tracker-file-utils.c	Tue Dec 16 14:32:11 2008
@@ -544,7 +544,8 @@
 }
 
 GSList *
-tracker_path_list_filter_duplicates (GSList *roots)
+tracker_path_list_filter_duplicates (GSList      *roots,
+				     const gchar *basename_exception_prefix)
 {
 	GSList *l1, *l2;
 	GSList *new_list;
@@ -568,8 +569,38 @@
 			
 			if (path == in_path) {
 				/* Do nothing */
+				l2 = l2->next;
+				continue;
 			} 
-			else if (tracker_path_is_in_path (path, in_path)) {
+
+			if (basename_exception_prefix) {
+				gchar *basename;
+				gboolean has_prefix = FALSE;
+
+				basename = g_path_get_basename (path);
+				if (!g_str_has_prefix (basename, basename_exception_prefix)) {
+					g_free (basename);
+					
+					basename = g_path_get_basename (in_path);
+					if (g_str_has_prefix (basename, basename_exception_prefix)) {
+						has_prefix = TRUE;
+					}	
+				} else {
+					has_prefix = TRUE;
+				}
+
+				g_free (basename);
+
+				/* This is so we can ignore this check
+				 * on files which prefix with ".".
+				 */
+				if (has_prefix) {
+					l2 = l2->next;
+					continue;
+				}
+			}
+
+			if (tracker_path_is_in_path (path, in_path)) {
 				g_debug ("Removing path:'%s', it is in path:'%s'",
 					 path, in_path);
 

Modified: branches/turtle/src/libtracker-common/tracker-file-utils.h
==============================================================================
--- branches/turtle/src/libtracker-common/tracker-file-utils.h	(original)
+++ branches/turtle/src/libtracker-common/tracker-file-utils.h	Tue Dec 16 14:32:11 2008
@@ -46,7 +46,8 @@
 gboolean tracker_path_is_in_path		   (const gchar *path,
 						    const gchar *in_path);
 void	 tracker_path_hash_table_filter_duplicates (GHashTable	*roots);
-GSList * tracker_path_list_filter_duplicates	   (GSList	*roots);
+GSList * tracker_path_list_filter_duplicates	   (GSList	*roots,
+						    const gchar *basename_exception_prefix);
 gchar *  tracker_path_evaluate_name		   (const gchar *uri);
 gboolean tracker_env_check_xdg_dirs		   (void);
 

Modified: branches/turtle/src/libtracker-common/tracker-thumbnailer.c
==============================================================================
--- branches/turtle/src/libtracker-common/tracker-thumbnailer.c	(original)
+++ branches/turtle/src/libtracker-common/tracker-thumbnailer.c	Tue Dec 16 14:32:11 2008
@@ -21,6 +21,8 @@
 
 #include "config.h"
 
+#include <string.h>
+
 #include <libtracker-data/tracker-data-metadata.h>
 
 #include <tracker-indexer/tracker-module-file.h>
@@ -307,8 +309,8 @@
 			  const gchar *to_uri)
 {
 	TrackerThumbnailerPrivate *private;
-	const gchar *to[2] = { NULL, NULL };
-	const gchar *from[2] = { NULL, NULL };
+	gchar *to[2] = { NULL, NULL };
+	gchar *from[2] = { NULL, NULL };
 
 	g_return_if_fail (from_uri != NULL);
 	g_return_if_fail (mime_type != NULL);
@@ -338,8 +340,16 @@
 		   to_uri,
 		   private->request_id); 
 
-	to[0] = to_uri;
-	from[0] = from_uri;
+	if (!strstr (to_uri, ":/"))
+		to[0] = g_strdup_printf ("file://%s", to_uri);
+	else
+		to[0] = g_strdup (to_uri);
+
+	if (!strstr (from_uri, ":/"))
+		from[0] = g_strdup_printf ("file://%s", from_uri);
+	else
+		from[0] = g_strdup (from_uri);
+
 	
 	dbus_g_proxy_begin_call (private->requester_proxy,
 				 "Move",
@@ -349,6 +359,10 @@
 				 G_TYPE_STRV, from,
 				 G_TYPE_STRV, to,
 				 G_TYPE_INVALID);
+
+	g_free (from[0]);
+	g_free (to[0]);
+
 }
 
 void
@@ -356,7 +370,7 @@
 			    const gchar *mime_type)
 {
 	TrackerThumbnailerPrivate *private;
-	const gchar *uris[2] = { NULL, NULL };
+	gchar *uris[2] = { NULL, NULL };
 
 	g_return_if_fail (uri != NULL);
 	g_return_if_fail (mime_type != NULL);
@@ -381,7 +395,10 @@
 
 	private->request_id++;
 
-	uris[0] = uri;
+	if (!strstr (uri, ":/"))
+		uris[0] = g_strdup_printf ("file://%s", uri);
+	else
+		uris[0] = g_strdup (uri);
 
 	g_message ("Requesting thumbnailer removes URI:'%s', request_id:%d...",
 		   uri,
@@ -392,8 +409,10 @@
 				 thumbnailer_reply_cb,
 				 GUINT_TO_POINTER (private->request_id),
 				 NULL,
-				 G_TYPE_STRV, uri,
+				 G_TYPE_STRV, uris,
 				 G_TYPE_INVALID);
+
+	g_free (uris[0]);
 }
 
 void 
@@ -471,8 +490,11 @@
 		thumbnailer_request_timeout_cb (NULL);
 	}
 
-	/* Add new URI */
-	private->uris[private->count] = g_strdup (uri);
+	/* Add new URI (detect if we got passed a path) */
+	if (!strstr (uri, ":/"))
+		private->uris[private->count] = g_strdup_printf ("file://%s", uri);
+	else
+		private->uris[private->count] = g_strdup (uri);
 
 	if (mime_type) {
 		private->mime_types[private->count] = g_strdup (mime_type);

Modified: branches/turtle/src/tracker-extract/tracker-albumart.c
==============================================================================
--- branches/turtle/src/tracker-extract/tracker-albumart.c	(original)
+++ branches/turtle/src/tracker-extract/tracker-albumart.c	Tue Dec 16 14:32:11 2008
@@ -553,11 +553,10 @@
 		   gchar       **path,
 		   gchar       **local)
 {
-
 	gchar *art_filename;
 	gchar *dir;
-	gchar *str;
-	gchar *down;
+	gchar *down1, *down2;
+	gchar *str1 = NULL, *str2 = NULL;
 	gchar *f_a = NULL, *f_b = NULL;
 
 	/* http://live.gnome.org/MediaArtStorageSpec */
@@ -568,48 +567,36 @@
 		return;
 	}
 
-	if (a)
+	if (a && strlen (a) > 1)
 		f_a = strip_characters (a);
+	else 
+		f_a = g_strdup ("  ");
 
-	if (b)
+	if (b && strlen (b) > 1)
 		f_b = strip_characters (b);
+	else
+		f_b = g_strdup ("  ");
 
-	str = g_strconcat (a ? f_a : "", 
-			   " ", 
-			   b ? f_b : "", 
-			   NULL);
+
+	down1 = g_utf8_strdown (f_a, -1);
+	down2 = g_utf8_strdown (f_b, -1);
 
 	g_free (f_a);
 	g_free (f_b);
 
-	down = g_utf8_strdown (str, -1);
-	g_free (str);
-
 	dir = g_build_filename (g_get_user_cache_dir (), "media-art", NULL);
 
 	if (!g_file_test (dir, G_FILE_TEST_EXISTS)) {
 		g_mkdir_with_parents (dir, 0770);
 	}
 
-	str = g_compute_checksum_for_string (G_CHECKSUM_MD5, down, -1);
-	g_free (down);
+	str1 = g_compute_checksum_for_string (G_CHECKSUM_MD5, down1, -1);
+	str2 = g_compute_checksum_for_string (G_CHECKSUM_MD5, down2, -1);
 
-	art_filename = g_strdup_printf ("%s-%s.jpeg", prefix?prefix:"album", str);
-	g_free (str);
+	g_free (down1);
+	g_free (down2);
 
-	if (local && uri) {
-		gchar *uri_t = g_strdup (uri);
-		gchar *ptr = strrchr (uri_t, '/');
-
-		if (ptr)
-			*ptr = '\0';
-
-		/* g_build_filename can't be used here, it's a URI */
-
-		*local = g_strdup_printf ("%s/.mediaartlocal/%s", 
-					  uri_t, art_filename);
-		g_free (uri_t);
-	}
+	art_filename = g_strdup_printf ("%s-%s-%s.jpeg", prefix?prefix:"album", str1, str2);
 
 	*path = g_build_filename (dir, art_filename, NULL);
 	g_free (dir);
@@ -664,15 +651,19 @@
 		return FALSE;
 	}
 
-	g_free (filename);
+
 	g_object_unref (pixbuf);
 
 	if (!gdk_pixbuf_loader_close (loader, &error)) {
 		g_warning ("%s\n", error->message);
 		g_error_free (error);
+		g_free (filename);
 		return FALSE;
 	}
 
+	tracker_thumbnailer_get_file_thumbnail (filename, "image/jpeg");
+	g_free (filename);
+
 	return TRUE;
 }
 
@@ -711,6 +702,9 @@
 					       artist,
 					       album,
 					       filename);
+
+			lcopied = retval;
+
 			
 		} else {
 #endif /* HAVE_GDK_PIXBUF */

Modified: branches/turtle/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/turtle/src/trackerd/tracker-crawler.c	(original)
+++ branches/turtle/src/trackerd/tracker-crawler.c	Tue Dec 16 14:32:11 2008
@@ -900,20 +900,17 @@
 
 	/* Filter duplicates */
 	l = priv->paths;
-	priv->paths = tracker_path_list_filter_duplicates (priv->paths);
-
+	priv->paths = tracker_path_list_filter_duplicates (priv->paths, ".");
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);
 
 	l = priv->recurse_paths;
-	priv->recurse_paths = tracker_path_list_filter_duplicates (priv->recurse_paths);
-
+	priv->recurse_paths = tracker_path_list_filter_duplicates (priv->recurse_paths, ".");
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);
 
 	l = priv->special_paths;
-	priv->special_paths = tracker_path_list_filter_duplicates (priv->special_paths);
-
+	priv->special_paths = tracker_path_list_filter_duplicates (priv->special_paths, ".");
 	g_slist_foreach (l, (GFunc) g_free, NULL);
 	g_slist_free (l);
 

Modified: branches/turtle/tests/libtracker-common/tracker-file-utils-test.c
==============================================================================
--- branches/turtle/tests/libtracker-common/tracker-file-utils-test.c	(original)
+++ branches/turtle/tests/libtracker-common/tracker-file-utils-test.c	Tue Dec 16 14:32:11 2008
@@ -64,8 +64,7 @@
 
 	input_as_list = array_as_list (input_roots);
 
-
-	result = tracker_path_list_filter_duplicates (input_as_list);
+	result = tracker_path_list_filter_duplicates (input_as_list, ".");
 	g_assert_cmpint (3, ==, g_slist_length (result));
 
 	g_assert (string_in_list (result, "/home"));



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