[rhythmbox] rhythmdb: bump database version, reload all metadata



commit 8db05c1960891e7e94b4a12123814814935112ae
Author: Jonathan Matthew <jonathan d14n org>
Date:   Tue Jun 15 16:21:59 2010 +1000

    rhythmdb: bump database version, reload all metadata
    
    This will ensure that various sortnames, album artist, BPM and comment
    are all read from tags.
    
    Mountpoints for local files are going to become important soon, so make
    sure those are up to date too.

 rhythmdb/rhythmdb-tree.c |   31 +++++++++++++++++++++++++++++--
 rhythmdb/rhythmdb.c      |    2 +-
 2 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/rhythmdb/rhythmdb-tree.c b/rhythmdb/rhythmdb-tree.c
index becd748..c99e475 100644
--- a/rhythmdb/rhythmdb-tree.c
+++ b/rhythmdb/rhythmdb-tree.c
@@ -115,8 +115,8 @@ static void rhythmdb_hash_tree_foreach (RhythmDB *adb,
 					gpointer data);
 
 /* Update both of those! */
-#define RHYTHMDB_TREE_XML_VERSION "1.6"
-#define RHYTHMDB_TREE_XML_VERSION_INT 160
+#define RHYTHMDB_TREE_XML_VERSION "1.7"
+#define RHYTHMDB_TREE_XML_VERSION_INT 170
 
 static void destroy_tree_property (RhythmDBTreeProperty *prop);
 static RhythmDBTreeProperty *get_or_create_album (RhythmDBTree *db, RhythmDBTreeProperty *artist,
@@ -334,6 +334,7 @@ struct RhythmDBTreeLoadContext
 	guint canonicalise_uris : 1;
 	guint reload_all_metadata : 1;
 	guint update_podcasts : 1;
+	guint update_local_mountpoints : 1;
 };
 
 /* Returns the version as an int, multiplied by 100,
@@ -395,6 +396,10 @@ rhythmdb_tree_parser_start_element (struct RhythmDBTreeLoadContext *ctx,
 					case 150:
 						rb_debug ("Upgrade Podcasts remote vs. local locations");
 						ctx->update_podcasts = TRUE;
+					case 160:
+						rb_debug ("reloading all file metadata to get sortnames, album artist, comments, bpm and updating mountpoints");
+						ctx->reload_all_metadata = TRUE;
+						ctx->update_local_mountpoints = TRUE;
 					case RHYTHMDB_TREE_XML_VERSION_INT:
 						/* current version */
 						break;
@@ -536,6 +541,28 @@ rhythmdb_tree_parser_end_element (struct RhythmDBTreeLoadContext *ctx,
 				ctx->entry->mountpoint = tmp;
 			}
 		}
+		if (ctx->entry->type == RHYTHMDB_ENTRY_TYPE_SONG) {
+			/* Since we now care about mountpoints for all local entries, not just
+			 * those on things that actually get mounted and unmounted, we need to
+			 * ensure they're all correct.
+			 */
+			if (ctx->update_local_mountpoints) {
+				const char *loc = rb_refstring_get (ctx->entry->location);
+				if (loc == NULL || g_str_has_prefix (loc, "file:///")) {
+					char *nmp;
+					nmp = rb_uri_get_mount_point (loc);
+					if (ctx->entry->mountpoint != NULL) {
+						rb_refstring_unref (ctx->entry->mountpoint);
+						ctx->entry->mountpoint = NULL;
+					}
+
+					if (nmp != NULL) {
+						ctx->entry->mountpoint = rb_refstring_new (nmp);
+						g_free (nmp);
+					}
+				}
+			}
+		}
 
 		if (ctx->entry->location != NULL && rb_refstring_get (ctx->entry->location)[0] != '\0') {
 			RhythmDBEntry *entry;
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index be33bdc..6f403b8 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -2525,7 +2525,7 @@ rhythmdb_process_metadata_load_real (RhythmDBEvent *event)
 	if (eel_gconf_get_boolean (CONF_MONITOR_LIBRARY) && event->entry_type == RHYTHMDB_ENTRY_TYPE_SONG)
 		rhythmdb_monitor_uri_path (event->db, rb_refstring_get (entry->location), NULL);
 
-	rhythmdb_commit (event->db);
+	rhythmdb_commit_internal (event->db, FALSE, g_thread_self ());
 
 	return TRUE;
 }



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