[tracker] libtracker-miner: avoid dead code in mount_guess_content_type()



commit 0b6cebf9fbec4c2b8c7ca6f8ed3fe646e6146294
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Wed Jul 7 12:16:38 2010 +0200

    libtracker-miner: avoid dead code in mount_guess_content_type()

 src/libtracker-miner/tracker-storage.c |   89 ++++++++++++++++----------------
 1 files changed, 45 insertions(+), 44 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-storage.c b/src/libtracker-miner/tracker-storage.c
index b57ef4c..9522bf2 100644
--- a/src/libtracker-miner/tracker-storage.c
+++ b/src/libtracker-miner/tracker-storage.c
@@ -357,7 +357,6 @@ mount_guess_content_type (GFile    *mount_root,
 	gchar *content_type = NULL;
 	gchar *mount_path;
 	gchar **guess_type;
-	gint i;
 
 	/* This function has 2 purposes:
 	 *
@@ -455,52 +454,54 @@ mount_guess_content_type (GFile    *mount_root,
 	 * the media.
 	 */
 	guess_type = g_content_type_guess_for_tree (mount_root);
+	if (guess_type) {
+		gint i = 0;
+
+		while (!content_type && guess_type[i]) {
+			if (!g_strcmp0 (guess_type[i], "x-content/image-picturecd")) {
+				/* Images */
+				content_type = g_strdup (guess_type[i]);
+			} else if (!g_strcmp0 (guess_type[i], "x-content/video-bluray") ||
+			           !g_strcmp0 (guess_type[i], "x-content/video-dvd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/video-hddvd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/video-svcd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/video-vcd")) {
+				/* Videos */
+				*is_multimedia = TRUE;
+				content_type = g_strdup (guess_type[i]);
+			} else if (!g_strcmp0 (guess_type[i], "x-content/audio-cdda") ||
+			           !g_strcmp0 (guess_type[i], "x-content/audio-dvd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/audio-player")) {
+				/* Audios */
+				*is_multimedia = TRUE;
+				content_type = g_strdup (guess_type[i]);
+			} else if (!g_strcmp0 (guess_type[i], "x-content/blank-bd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/blank-cd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/blank-dvd") ||
+			           !g_strcmp0 (guess_type[i], "x-content/blank-hddvd")) {
+				/* Blank */
+				*is_blank = TRUE;
+				content_type = g_strdup (guess_type[i]);
+			} else if (!g_strcmp0 (guess_type[i], "x-content/software") ||
+			           !g_strcmp0 (guess_type[i], "x-content/unix-software") ||
+			           !g_strcmp0 (guess_type[i], "x-content/win32-software")) {
+				/* NOTE: This one is a guess, can we
+				 * have this content type on
+				 * none-optical mount points?
+				 */
+				content_type = g_strdup (guess_type[i]);
+			} else {
+				/* else, keep on with the next guess, if any */
+				i++;
+			}
+		}
 
-	for (i = 0; guess_type && guess_type[i]; i++) {
-		if (!g_strcmp0 (guess_type[i], "x-content/image-picturecd")) {
-			/* Images */
-			content_type = g_strdup (guess_type[i]);
-			break;
-		} else if (!g_strcmp0 (guess_type[i], "x-content/video-bluray") ||
-			   !g_strcmp0 (guess_type[i], "x-content/video-dvd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/video-hddvd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/video-svcd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/video-vcd")) {
-			/* Videos */
-			*is_multimedia = TRUE;
-			content_type = g_strdup (guess_type[i]);
-			break;
-		} else if (!g_strcmp0 (guess_type[i], "x-content/audio-cdda") ||
-			   !g_strcmp0 (guess_type[i], "x-content/audio-dvd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/audio-player")) {
-			/* Audios */
-			*is_multimedia = TRUE;
-			content_type = g_strdup (guess_type[i]);
-			break;
-		} else if (!g_strcmp0 (guess_type[i], "x-content/blank-bd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/blank-cd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/blank-dvd") ||
-			   !g_strcmp0 (guess_type[i], "x-content/blank-hddvd")) {
-			/* Blank */
-			*is_blank = TRUE;
-			content_type = g_strdup (guess_type[i]);
-			break;
-		} else if (!g_strcmp0 (guess_type[i], "x-content/software") ||
-			   !g_strcmp0 (guess_type[i], "x-content/unix-software") ||
-			   !g_strcmp0 (guess_type[i], "x-content/win32-software")) {
-			/* NOTE: This one is a guess, can we
-			 * have this content type on
-			 * none-optical mount points?
-			 */
-			content_type = g_strdup (guess_type[i]);
-			break;
-		} else if (!content_type) {
-			content_type = g_strdup (guess_type[i]);
-			break;
+		/* If we didn't have an exact match on possible guessed content types,
+		 *  then use the first one returned (best guess always first) if any */
+		if (!content_type && guess_type[0]) {
+			content_type = g_strdup (guess_type[0]);
 		}
-	}
 
-	if (guess_type) {
 		g_strfreev (guess_type);
 	}
 



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