tracker r2402 - trunk/src/tracker-extract



Author: pvanhoof
Date: Tue Oct 21 12:29:07 2008
New Revision: 2402
URL: http://svn.gnome.org/viewvc/tracker?rev=2402&view=rev

Log:
One more optimization

Modified:
   trunk/src/tracker-extract/tracker-albumart.c

Modified: trunk/src/tracker-extract/tracker-albumart.c
==============================================================================
--- trunk/src/tracker-extract/tracker-albumart.c	(original)
+++ trunk/src/tracker-extract/tracker-albumart.c	Tue Oct 21 12:29:07 2008
@@ -85,11 +85,8 @@
 		gint count = 0;
 
 		if (dir) {
-			gchar *target;
-			GFile *file2;
-
-			tracker_get_albumart_path (artist, album, "album", &target);
-			file2 = g_file_new_for_path (target);
+			gchar *target = NULL;
+			GFile *file2 = NULL;
 
 			for (filen = g_dir_read_name (dir); filen; filen = g_dir_read_name (dir))
 				count++;
@@ -106,6 +103,12 @@
 						if (g_str_has_suffix (filen, "jpeg") || g_str_has_suffix (filen, "jpg")) {
 							GFile *file1;
 
+							if (!target)
+								tracker_get_albumart_path (artist, album, "album", &target);
+
+							if (!file2)
+								file2 = g_file_new_for_path (target);
+
 							found = g_build_filename (dirp, filen, NULL);
  							file1 = g_file_new_for_path (found);
 
@@ -131,6 +134,10 @@
 								g_error_free (error);
 								retval = FALSE;
 							} else {
+
+								if (!target)
+									tracker_get_albumart_path (artist, album, "album", &target);
+
 								gdk_pixbuf_save (pixbuf, target, "jpeg", &error, NULL);
 								if (!error)
 									retval = TRUE;
@@ -154,7 +161,8 @@
 			}
 
 			g_dir_close (dir);
-			g_object_unref (file2);
+			if (file2)
+				g_object_unref (file2);
 			g_free (target);
 
 		}



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