summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2010-07-07 12:16:38 +0200
committerArnel A. Borja <arnelborja@src.gnome.org>2013-08-31 00:56:45 +0800
commit7ec03f16191e399f95abd200501f02728243b78b (patch)
tree8eeec020c8b0531bb6e1395d68e648aacd2d7c30
parentaaf7c94ae076e17b35c7b81b2713fd02b62f3bef (diff)
downloadlibmediaart-7ec03f16191e399f95abd200501f02728243b78b.tar.gz
libtracker-miner: avoid dead code in mount_guess_content_type()
-rw-r--r--src/libtracker-miner/tracker-storage.c89
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);
}