[rhythmbox] rhythmdb: minor tweaks to import error and missing plugin handling



commit d9e916ba7e2db17abc01e30bf30e79d7f5aad1a6
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Jun 19 14:28:27 2010 +1000

    rhythmdb: minor tweaks to import error and missing plugin handling

 rhythmdb/rhythmdb-import-job.c |    4 ++--
 rhythmdb/rhythmdb.c            |   31 +++++++++++++++++++------------
 2 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/rhythmdb/rhythmdb-import-job.c b/rhythmdb/rhythmdb-import-job.c
index ec9bf20..2c8b633 100644
--- a/rhythmdb/rhythmdb-import-job.c
+++ b/rhythmdb/rhythmdb-import-job.c
@@ -197,7 +197,7 @@ emit_status_changed (RhythmDBImportJob *job)
 	g_static_mutex_lock (&job->priv->lock);
 	job->priv->status_changed_id = 0;
 
-	rb_debug ("emitting status changed: %d/%d", job->priv->total, job->priv->imported);
+	rb_debug ("emitting status changed: %d/%d", job->priv->imported, job->priv->total);
 	g_signal_emit (job, signals[STATUS_CHANGED], 0, job->priv->total, job->priv->imported);
 
 	/* temporary ref while emitting this signal as we're expecting the caller
@@ -444,7 +444,7 @@ entry_added_cb (RhythmDB *db,
 		/* if it's an import error with missing plugins, add it to the retry list */
 		details = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_COMMENT);
 		if (rhythmdb_entry_get_entry_type (entry) == job->priv->error_type &&
-		    (details != NULL || details[0] != '\0')) {
+		    (details != NULL && details[0] != '\0')) {
 			rb_debug ("entry %s is an import error with missing plugin details: %s", uri, details);
 			job->priv->retry_entries = g_slist_prepend (job->priv->retry_entries, rhythmdb_entry_ref (entry));
 		}
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index c8077d3..ec562bf 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -2287,7 +2287,10 @@ rhythmdb_add_import_error_entry (RhythmDB *db,
 	RhythmDBEntry *entry;
 	GValue value = {0,};
 
-	rb_debug ("adding import error for %s: %s", rb_refstring_get (event->real_uri), event->error ? event->error->message : "<no error>");
+	rb_debug ("adding import error type %s for %s: %s",
+		  error_entry_type->name,
+		  rb_refstring_get (event->real_uri),
+		  event->error ? event->error->message : "<no error>");
 	if (error_entry_type == RHYTHMDB_ENTRY_TYPE_INVALID) {
 		/* we don't have an error entry type, so we can't add an import error */
 		return;
@@ -2397,21 +2400,25 @@ rhythmdb_process_metadata_load (RhythmDB *db, RhythmDBEvent *event)
 	if (event->entry_type == RHYTHMDB_ENTRY_TYPE_INVALID)
 		event->entry_type = RHYTHMDB_ENTRY_TYPE_SONG;
 
-	/*
-	 * always ignore anything with video in it, or anything
-	 * matching one of the media types we don't care about.
-	 * if we can identify it that much, we know it's not interesting.
-	 * otherwise, add an import error entry if there was an error,
-	 * or just ignore it if it doesn't contain audio.
-	 */
 	if (event->metadata != NULL) {
-		const char *media_type = rb_metadata_get_mime (event->metadata);
-		if (rb_metadata_has_video (event->metadata) ||
-                    rb_metadata_has_audio (event->metadata) == FALSE ||
-		    (media_type != NULL && rhythmdb_ignore_media_type (media_type))) {
+		/* always ignore anything with video in it */
+		if (rb_metadata_has_video (event->metadata)) {
 			rhythmdb_add_import_error_entry (db, event, event->ignore_type);
 			return TRUE;
 		}
+
+		/* if we identified the media type, we can ignore anything
+		 * that matches one of the media types we don't care about,
+		 * as well as anything that doesn't contain audio.
+		 */
+		const char *media_type = rb_metadata_get_mime (event->metadata);
+		if (media_type != NULL && media_type[0] != '\0') {
+			if (rhythmdb_ignore_media_type (media_type) ||
+			    rb_metadata_has_audio (event->metadata) == FALSE) {
+				rhythmdb_add_import_error_entry (db, event, event->ignore_type);
+				return TRUE;
+			}
+		}
 	}
 
 	/* also ignore really small files we can't identify */



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