[rhythmbox] rhythmdb: make import jobs deal with entry types better



commit c0c2d5ca832ca873f597c5469dc829c81c1386d2
Author: Jonathan Matthew <jonathan d14n org>
Date:   Sat Sep 22 22:06:39 2012 +1000

    rhythmdb: make import jobs deal with entry types better
    
    If an existing entry is of a completely different type (not just
    the ignore or error type that we're importing), don't try to
    re-add it.

 rhythmdb/rhythmdb-import-job.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/rhythmdb/rhythmdb-import-job.c b/rhythmdb/rhythmdb-import-job.c
index e9fcde3..c4da003 100644
--- a/rhythmdb/rhythmdb-import-job.c
+++ b/rhythmdb/rhythmdb-import-job.c
@@ -262,12 +262,16 @@ static void
 uri_recurse_func (GFile *file, gboolean dir, RhythmDBImportJob *job)
 {
 	RhythmDBEntry *entry;
+	gboolean add_uri;
 	char *uri;
 
 	if (dir) {
 		return;
 	}
 
+	if (g_cancellable_is_cancelled (job->priv->cancel))
+		return;
+
 	uri = g_file_get_uri (file);
 
 	/* only add the entry to the map of entries we're waiting for
@@ -285,13 +289,28 @@ uri_recurse_func (GFile *file, gboolean dir, RhythmDBImportJob *job)
 		}
 
 		g_mutex_unlock (&job->priv->lock);
+
+		add_uri = TRUE;
+	} else {
+		/* skip it if it's a different entry type */
+		RhythmDBEntryType *et;
+		et = rhythmdb_entry_get_entry_type (entry);
+		if (et != job->priv->entry_type &&
+		    et != job->priv->ignore_type &&
+		    et != job->priv->error_type) {
+			add_uri = FALSE;
+		} else {
+			add_uri = TRUE;
+		}
 	}
 
-	rhythmdb_add_uri_with_types (job->priv->db,
-				     uri,
-				     job->priv->entry_type,
-				     job->priv->ignore_type,
-				     job->priv->error_type);
+	if (add_uri) {
+		rhythmdb_add_uri_with_types (job->priv->db,
+					     uri,
+					     job->priv->entry_type,
+					     job->priv->ignore_type,
+					     job->priv->error_type);
+	}
 	g_free (uri);
 }
 



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