rhythmbox r5906 - in trunk: . podcast rhythmdb tests



Author: hadess
Date: Thu Sep 11 16:02:31 2008
New Revision: 5906
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5906&view=rev

Log:
2008-09-11  Bastien Nocera  <hadess hadess net>

	* podcast/rb-feed-podcast-properties-dialog.c
	(rb_feed_podcast_properties_dialog_update_location):
	* podcast/rb-podcast-manager.c (get_download_location),
	(set_download_location), (get_remote_location),
	(rb_podcast_manager_download_entry),
	(rb_podcast_manager_entry_downloaded),
	(rb_podcast_manager_head_query_cb), (download_error),
	(rb_podcast_manager_next_file), (download_file_info_cb),
	(rb_podcast_manager_save_metadata), (download_progress),
	(podcast_download_thread), (end_job), (cancel_job),
	(rb_podcast_manager_db_entry_deleted_cb),
	(remove_if_not_downloaded):
	* podcast/rb-podcast-properties-dialog.c
	(rb_podcast_properties_dialog_update_location),
	(rb_podcast_properties_dialog_update_download_location):
	* rhythmdb/rhythmdb-tree.c (rhythmdb_tree_parser_start_element),
	(rhythmdb_tree_parser_end_element):
	* rhythmdb/rhythmdb.c (process_deleted_entries_cb):
	Forbid podcasts from showing up in the main library, by using
	the local download location to identify the file as soon as we start
	downloading it (Closes: #323440)

	* tests/podcast-upgrade.xml:
	* tests/test-rhythmdb.c (START_TEST), (rhythmdb_suite), (main):
	Add a test for the database upgrade code above



Added:
   trunk/tests/podcast-upgrade.xml
Modified:
   trunk/ChangeLog
   trunk/podcast/rb-feed-podcast-properties-dialog.c
   trunk/podcast/rb-podcast-manager.c
   trunk/podcast/rb-podcast-properties-dialog.c
   trunk/rhythmdb/rhythmdb-tree.c
   trunk/rhythmdb/rhythmdb.c
   trunk/tests/test-rhythmdb.c

Modified: trunk/podcast/rb-feed-podcast-properties-dialog.c
==============================================================================
--- trunk/podcast/rb-feed-podcast-properties-dialog.c	(original)
+++ trunk/podcast/rb-feed-podcast-properties-dialog.c	Thu Sep 11 16:02:31 2008
@@ -243,7 +243,9 @@
 	const char *location;
 	char *unescaped;
 
-	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
+	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_MOUNTPOINT);
+	if (location == NULL)
+		location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
 	unescaped = g_uri_unescape_string (location, NULL);
 	gtk_label_set_text (GTK_LABEL (dialog->priv->location), unescaped);
 	g_free (unescaped);

Modified: trunk/podcast/rb-podcast-manager.c
==============================================================================
--- trunk/podcast/rb-podcast-manager.c	(original)
+++ trunk/podcast/rb-podcast-manager.c	Thu Sep 11 16:02:31 2008
@@ -429,6 +429,49 @@
 	return pd;
 }
 
+static const char *
+get_download_location (RhythmDBEntry *entry)
+{
+	/* We haven't tried to download the entry yet */
+	if (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT) == NULL)
+		return NULL;
+	return rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
+}
+
+static void
+set_download_location (RhythmDB *db, RhythmDBEntry *entry, GValue *value)
+{
+	char *remote_location;
+
+	if (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT) == NULL) {
+		/* If the download location was never set */
+		GValue val = {0, };
+
+		/* Save the remote location */
+		remote_location = g_strdup (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
+		/* Set the new download location */
+		rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_LOCATION, value);
+		/* Set MOUNTPOINT to the remote location */
+		g_value_init (&val, G_TYPE_STRING);
+		g_value_take_string (&val, remote_location);
+		rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_MOUNTPOINT, &val);
+		g_value_unset (&val);
+	} else {
+		/* Just update the location */
+		rhythmdb_entry_set (db, entry, RHYTHMDB_PROP_LOCATION, value);
+	}
+}
+
+static const char *
+get_remote_location (RhythmDBEntry *entry)
+{
+	const char *location;
+	location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT);
+	if (location == NULL)
+		location = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
+	return location;
+}
+
 void
 rb_podcast_manager_download_entry (RBPodcastManager *pd,
 				   RhythmDBEntry *entry)
@@ -454,8 +497,7 @@
 
 			rhythmdb_commit (pd->priv->db);
 		}
-		rb_debug ("Adding podcast episode %s to download list",
-			  rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
+		rb_debug ("Adding podcast episode %s to download list", get_remote_location (entry));
 
 		data = g_new0 (RBPodcastManagerInfo, 1);
 		data->pd = g_object_ref (pd);
@@ -479,7 +521,7 @@
 	g_assert (type == RHYTHMDB_ENTRY_TYPE_PODCAST_POST);
 
 	status = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_STATUS);
-	file_name = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT);
+	file_name = get_download_location (entry);
 
 	return (status != RHYTHMDB_PODCAST_STATUS_ERROR && file_name != NULL);
 }
@@ -564,7 +606,7 @@
 	guint status;
 
         gtk_tree_model_get (query_model, iter, 0, &entry, -1);
-        uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION);
+        uri = get_remote_location (entry);
 	status = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_STATUS);
 
 	if (status == 1)
@@ -580,7 +622,7 @@
 {
 	GValue val = {0,};
 	rb_debug ("error downloading %s: %s",
-		  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION),
+		  get_remote_location (data->entry),
 		  error->message);
 
 	g_value_init (&val, G_TYPE_ULONG);
@@ -633,7 +675,7 @@
 
 	pd->priv->active_download = data;
 
-	location = rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION);
+	location = get_remote_location (data->entry);
 	rb_debug ("processing %s", location);
 
 	/* extract the query string so we can remove it later if it appears
@@ -679,7 +721,7 @@
 	g_assert (rb_is_main_thread ());
 
 	rb_debug ("got file info results for %s",
-		  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION));
+		  get_remote_location (data->entry));
 
 	src_info = g_file_query_info_finish (source, result, &error);
 
@@ -812,7 +854,7 @@
 
 			g_value_init (&val, G_TYPE_STRING);
 			g_value_take_string (&val, g_file_get_uri (data->destination));
-			rhythmdb_entry_set (data->pd->priv->db, data->entry, RHYTHMDB_PROP_MOUNTPOINT, &val);
+			set_download_location (data->pd->priv->db, data->entry, &val);
 			g_value_unset (&val);
 
 			rb_podcast_manager_save_metadata (data->pd, data->entry);
@@ -1176,7 +1218,7 @@
 	char **missing_plugins;
 	char **plugin_descriptions;
 
-	uri = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT);
+	uri = get_download_location (entry);
 	rb_debug ("loading podcast metadata from %s", uri);
         rb_metadata_load (md, uri, &error);
 
@@ -1298,7 +1340,6 @@
 {
 	guint local_progress = 0;
 
-
 	if (downloaded > 0 && total > 0)
 		local_progress = (100 * downloaded) / total;
 
@@ -1330,7 +1371,7 @@
 		if (g_cancellable_is_cancelled (data->cancel) == FALSE) {
 			GValue val = {0,};
 			rb_debug ("download of %s completed",
-				  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION));
+				  get_remote_location (data->entry));
 
 			g_value_init (&val, G_TYPE_UINT64);
 			g_value_set_uint64 (&val, downloaded);
@@ -1398,6 +1439,22 @@
 		return NULL;
 	}
 
+	/* set the downloaded location for the episode
+	 * and do it before opening the file, so that the monitor
+	 * doesn't add a normal entry for us */
+	if (get_download_location (data->entry) == NULL) {
+		GValue val = {0,};
+		char *uri = g_file_get_uri (data->destination);
+
+		g_value_init (&val, G_TYPE_STRING);
+		g_value_set_string (&val, uri);
+		set_download_location (data->pd->priv->db, data->entry, &val);
+		g_value_unset (&val);
+
+		rhythmdb_commit (data->pd->priv->db);
+		g_free (uri);
+	}
+
 	/* gvfs doesn't do file info queries from streams, so this doesn't help, but
 	 * maybe some day it will..
 	 */
@@ -1431,20 +1488,6 @@
 		}
 	}
 	
-	/* set the downloaded location for the episode */
-	if (rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_MOUNTPOINT) == NULL) {
-		GValue val = {0,};
-		char *uri = g_file_get_uri (data->destination);
-
-		g_value_init (&val, G_TYPE_STRING);
-		g_value_set_string (&val, uri);
-		rhythmdb_entry_set (data->pd->priv->db, data->entry, RHYTHMDB_PROP_MOUNTPOINT, &val);
-		g_value_unset (&val);
-
-		rhythmdb_commit (data->pd->priv->db);
-		g_free (uri);
-	}
-
 	/* loop, copying from input stream to output stream */
 	while (TRUE) {
 		char *p;
@@ -1469,6 +1512,8 @@
 			n_read -= n_written;
 			downloaded += n_written;
 		}
+		if (n_written == -1)
+			break;
 
 		download_progress (data, downloaded, data->download_size, FALSE);
 	}
@@ -1495,7 +1540,7 @@
 	g_assert (rb_is_main_thread ());
 
 	rb_debug ("cleaning up download of %s",
-		  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION));
+		  get_remote_location (data->entry));
 
 	data->pd->priv->download_list = g_list_remove (data->pd->priv->download_list, data);
 
@@ -1520,8 +1565,7 @@
 cancel_job (RBPodcastManagerInfo *data)
 {
 	g_assert (rb_is_main_thread ());
-	rb_debug ("cancelling download of %s",
-		  rhythmdb_entry_get_string (data->entry, RHYTHMDB_PROP_LOCATION));
+	rb_debug ("cancelling download of %s", get_remote_location (data->entry));
 
 	/* is this the active download? */
 	if (data == data->pd->priv->active_download) {
@@ -1582,7 +1626,7 @@
 		/* make sure we're not downloading it */
 		rb_podcast_manager_cancel_download (pd, entry);
 
-		file_name = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT);
+		file_name = get_download_location (entry);
 		if (file_name == NULL) {
 			/* episode has not been downloaded */
 			rb_debug ("Episode not downloaded, skipping.");
@@ -1621,7 +1665,7 @@
                 	                RHYTHMDB_QUERY_PROP_EQUALS,
                         	        RHYTHMDB_PROP_TYPE, RHYTHMDB_ENTRY_TYPE_PODCAST_POST,
                 	                RHYTHMDB_QUERY_PROP_LIKE,
-					RHYTHMDB_PROP_SUBTITLE, rhythmdb_entry_get_string (entry,  RHYTHMDB_PROP_LOCATION),
+					RHYTHMDB_PROP_SUBTITLE, get_remote_location (entry),
                                 	RHYTHMDB_QUERY_END);
 
 		if (gtk_tree_model_get_iter_first (query_model, &iter)) {
@@ -1729,7 +1773,7 @@
 						    iter);
 	if (entry != NULL && rb_podcast_manager_entry_downloaded (entry) == FALSE) {
 		rb_debug ("entry %s is no longer present in the feed and has not been downloaded",
-			  rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION));
+			  get_remote_location (entry));
 		*remove = g_list_prepend (*remove, entry);
 	}
 

Modified: trunk/podcast/rb-podcast-properties-dialog.c
==============================================================================
--- trunk/podcast/rb-podcast-properties-dialog.c	(original)
+++ trunk/podcast/rb-podcast-properties-dialog.c	Thu Sep 11 16:02:31 2008
@@ -402,7 +402,9 @@
 	const char *location;
 	char *display;
 
-	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
+	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_MOUNTPOINT);
+	if (location == NULL)
+		location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
 	display = g_uri_unescape_string (location, NULL);
 	gtk_label_set_text (GTK_LABEL (dialog->priv->location), display);
 	g_free (display);
@@ -416,6 +418,7 @@
 	location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_MOUNTPOINT);
 	if (location != NULL && location[0] != '\0') {
 		char *display;
+		location = rhythmdb_entry_get_string (dialog->priv->current_entry, RHYTHMDB_PROP_LOCATION);
 		display = g_uri_unescape_string (location, NULL);
 		gtk_label_set_text (GTK_LABEL (dialog->priv->download_location), display);
 		g_free (display);

Modified: trunk/rhythmdb/rhythmdb-tree.c
==============================================================================
--- trunk/rhythmdb/rhythmdb-tree.c	(original)
+++ trunk/rhythmdb/rhythmdb-tree.c	Thu Sep 11 16:02:31 2008
@@ -117,8 +117,8 @@
 					gpointer data);
 
 /* Update both of those! */
-#define RHYTHMDB_TREE_XML_VERSION "1.5"
-#define RHYTHMDB_TREE_XML_VERSION_INT 150
+#define RHYTHMDB_TREE_XML_VERSION "1.6"
+#define RHYTHMDB_TREE_XML_VERSION_INT 160
 
 static void destroy_tree_property (RhythmDBTreeProperty *prop);
 static RhythmDBTreeProperty *get_or_create_album (RhythmDBTree *db, RhythmDBTreeProperty *artist,
@@ -332,9 +332,10 @@
 	GError **error;
 
 	/* updating */
-	gboolean has_date;
-	gboolean canonicalise_uris;
-	gboolean reload_all_metadata;
+	guint has_date : 1;
+	guint canonicalise_uris : 1;
+	guint reload_all_metadata : 1;
+	guint update_podcasts : 1;
 };
 
 /* Returns the version as an int, multiplied by 100,
@@ -392,6 +393,9 @@
 							rb_debug ("old version of rhythmdb, performing URI canonicalisation for all entries (DB version %s)", version);
 							ctx->canonicalise_uris = TRUE;
 						}
+					case 150:
+						rb_debug ("Upgrade Podcasts remote vs. local locations");
+						ctx->update_podcasts = TRUE;
 					case RHYTHMDB_TREE_XML_VERSION_INT:
 						/* current version */
 						break;
@@ -520,6 +524,19 @@
 				podcast->post_time = ctx->entry->last_seen;
 			}
 		}
+		if (ctx->entry->type == RHYTHMDB_ENTRY_TYPE_PODCAST_POST) {
+			/* When upgrading Podcasts from 0.11.6 and prior, we need to
+			 * swap mountpoint and location if there is a mountpoint */
+			if (ctx->update_podcasts && ctx->entry->mountpoint != NULL) {
+				RBRefString *tmp;
+
+				rb_debug ("pre-Podcast avoidance found, swapping location/mountpoint");
+
+				tmp = ctx->entry->location;
+				ctx->entry->location = ctx->entry->mountpoint;
+				ctx->entry->mountpoint = tmp;
+			}
+		}
 
 		if (ctx->entry->location != NULL && rb_refstring_get (ctx->entry->location)[0] != '\0') {
 			RhythmDBEntry *entry;
@@ -533,9 +550,33 @@
 					rhythmdb_commit (RHYTHMDB (ctx->db));
 					ctx->batch_count = 0;
 				}
+			} else if (ctx->entry->type == RHYTHMDB_ENTRY_TYPE_PODCAST_POST &&
+				   entry->type == RHYTHMDB_ENTRY_TYPE_SONG) {
+				rb_debug ("found song entry with duplicate location for Podcast post %s. merging metadata",
+					  rb_refstring_get (ctx->entry->location));
+
+				ctx->entry->play_count += entry->play_count;
+				if (ctx->entry->last_played < entry->last_played)
+					ctx->entry->last_played = entry->last_played;
+
+				/* Remove the song entry,
+				 * deleting requires relinquishing the locks */
+				g_mutex_unlock (ctx->db->priv->entries_lock);
+				rhythmdb_entry_delete (RHYTHMDB(ctx->db), entry);
+				g_mutex_lock (ctx->db->priv->entries_lock);
+				rhythmdb_commit (RHYTHMDB (ctx->db));
+
+				/* And add the Podcast entry to the database */
+				rhythmdb_tree_entry_new_internal (RHYTHMDB (ctx->db), ctx->entry);
+				rhythmdb_entry_insert (RHYTHMDB (ctx->db), ctx->entry);
+				if (++ctx->batch_count == RHYTHMDB_QUERY_MODEL_SUGGESTED_UPDATE_CHUNK) {
+					rhythmdb_commit (RHYTHMDB (ctx->db));
+					ctx->batch_count = 0;
+				}
 			} else {
 				rb_debug ("found entry with duplicate location %s. merging metadata",
 					  rb_refstring_get (ctx->entry->location));
+
 				entry->play_count += ctx->entry->play_count;
 
 				if (entry->rating < 0.01)

Modified: trunk/rhythmdb/rhythmdb.c
==============================================================================
--- trunk/rhythmdb/rhythmdb.c	(original)
+++ trunk/rhythmdb/rhythmdb.c	Thu Sep 11 16:02:31 2008
@@ -1232,6 +1232,8 @@
 		return FALSE;
 
 	rhythmdb_entry_ref (entry);
+	g_assert ((entry->flags & RHYTHMDB_ENTRY_INSERTED) != 0);
+	entry->flags &= ~(RHYTHMDB_ENTRY_INSERTED);
 	db->priv->deleted_entries_to_emit = g_list_prepend (db->priv->deleted_entries_to_emit, entry);
 
 	return TRUE;

Added: trunk/tests/podcast-upgrade.xml
==============================================================================
--- (empty file)
+++ trunk/tests/podcast-upgrade.xml	Thu Sep 11 16:02:31 2008
@@ -0,0 +1,93 @@
+<?xml version="1.0" standalone="yes"?>
+<rhythmdb version="1.5">
+  <entry type="song">
+    <title>Xtra: Sport</title>
+    <genre>Podcast</genre>
+    <artist>BBC World Service</artist>
+    <album>BBC Xtra</album>
+    <duration>1228</duration>
+    <file-size>9884221</file-size>
+    <location>file:///home/tester/Desktop/BBC%20Xtra/xtra_20080906-1226a.mp3</location>
+    <mtime>1220877218</mtime>
+    <first-seen>1220878173</first-seen>
+    <last-seen>1220878173</last-seen>
+    <bitrate>64</bitrate>
+    <date>733042</date>
+    <mimetype>application/x-id3</mimetype>
+    <hidden>1</hidden>
+    <mb-trackid></mb-trackid>
+    <mb-artistid></mb-artistid>
+    <mb-albumid></mb-albumid>
+    <mb-albumartistid></mb-albumartistid>
+    <mb-artistsortname></mb-artistsortname>
+  </entry>
+  <entry type="podcast-feed">
+    <title>BBC Xtra</title>
+    <genre></genre>
+    <artist>BBC World Service</artist>
+    <album></album>
+    <location>http://downloads.bbc.co.uk/podcasts/worldservice/xtra/rss.xml</location>
+    <last-seen>1220881374</last-seen>
+    <date>0</date>
+    <mimetype>application/octet-stream</mimetype>
+    <status>1</status>
+    <description>BBC Xtra is the flagship daily 2 hour live magazine programme on BBC Arabic, driving social and human interest issues onto the main news agenda of the Arabic Service. In a fast, energetic and relaxed style, BBC Xtra tackles difficult and controversial social affairs, as well as arts, literature and sports. BBC Xtra has a strong interactive element, where listeners contribute with their viewpoints on all topics by phone, SMS and e-mails.</description>
+    <lang>fa</lang>
+    <copyright>(C) BBC 2008</copyright>
+    <image>http://www.bbc.co.uk/radio/podcasts/xtra/assets/_300x300.jpg</image>
+    <post-time>1220701160</post-time>
+    <mb-trackid></mb-trackid>
+    <mb-artistid></mb-artistid>
+    <mb-albumid></mb-albumid>
+    <mb-albumartistid></mb-albumartistid>
+    <mb-artistsortname></mb-artistsortname>
+  </entry>
+  <entry type="podcast-post">
+    <title>Xtra: Sport</title>
+    <genre>Podcast</genre>
+    <artist>BBC World Service</artist>
+    <album>BBC Xtra</album>
+    <duration>1228</duration>
+    <file-size>9884221</file-size>
+    <location>http://downloads.bbc.co.uk/podcasts/worldservice/xtra/xtra_20080906-1226a.mp3</location>
+    <mountpoint>file:///home/tester/Desktop/BBC%20Xtra/xtra_20080906-1226a.mp3</mountpoint>
+    <mtime>1220881385</mtime>
+    <first-seen>1220881374</first-seen>
+    <last-seen>1220881388</last-seen>
+    <rating>2.5</rating>
+    <bitrate>64</bitrate>
+    <date>733042</date>
+    <mimetype>application/x-id3</mimetype>
+    <status>100</status>
+    <description>Sport </description>
+    <subtitle>http://downloads.bbc.co.uk/podcasts/worldservice/xtra/rss.xml</subtitle>
+    <post-time>1220700360</post-time>
+    <mb-trackid></mb-trackid>
+    <mb-artistid></mb-artistid>
+    <mb-albumid></mb-albumid>
+    <mb-albumartistid></mb-albumartistid>
+    <mb-artistsortname></mb-artistsortname>
+  </entry>
+  <entry type="podcast-post">
+    <title>Xtra: Football Clubs</title>
+    <genre>Podcast</genre>
+    <artist>BBC World Service</artist>
+    <album>BBC Xtra</album>
+    <duration>1438</duration>
+    <file-size>11561126</file-size>
+    <location>http://downloads.bbc.co.uk/podcasts/worldservice/xtra/xtra_20080903-1217a.mp3</location>
+    <first-seen>1220881374</first-seen>
+    <rating>2.5</rating>
+    <date>0</date>
+    <mimetype>application/octet-stream</mimetype>
+    <status>103</status>
+    <description>Football Clubs</description>
+    <subtitle>http://downloads.bbc.co.uk/podcasts/worldservice/xtra/rss.xml</subtitle>
+    <post-time>1220440620</post-time>
+    <mb-trackid></mb-trackid>
+    <mb-artistid></mb-artistid>
+    <mb-albumid></mb-albumid>
+    <mb-albumartistid></mb-albumartistid>
+    <mb-artistsortname></mb-artistsortname>
+  </entry>
+</rhythmdb>

Modified: trunk/tests/test-rhythmdb.c
==============================================================================
--- trunk/tests/test-rhythmdb.c	(original)
+++ trunk/tests/test-rhythmdb.c	Thu Sep 11 16:02:31 2008
@@ -44,7 +44,6 @@
 
 
 
-
 static void
 set_true (RhythmDBEntry *entry, gboolean *b)
 {
@@ -404,6 +403,31 @@
 }
 END_TEST
 
+START_TEST (test_rhythmdb_podcast_upgrade)
+{
+	RhythmDBEntry *entry;
+	const char *mountpoint;
+
+	/* load db with old podcasts setups */
+	g_object_set (G_OBJECT (db), "name", "podcast-upgrade.xml", NULL);
+	set_waiting_signal (G_OBJECT (db), "load-complete");
+	rhythmdb_load (db);
+	wait_for_signal ();
+
+	entry = rhythmdb_entry_lookup_by_location (db, "file:///home/tester/Desktop/BBC%20Xtra/xtra_20080906-1226a.mp3");
+
+	fail_unless (entry != NULL, "entry missing");
+	fail_unless (rhythmdb_entry_get_entry_type (entry) == RHYTHMDB_ENTRY_TYPE_PODCAST_POST, "entry isn't a podcast");
+	mountpoint = rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT);
+
+	fail_unless (mountpoint != NULL, "no mountpoint for podcast");
+	fail_unless (strcmp (mountpoint, "http://downloads.bbc.co.uk/podcasts/worldservice/xtra/xtra_20080906-1226a.mp3";) == 0, "wrong mountpoint for podcast");
+
+	entry = rhythmdb_entry_lookup_by_location (db, "http://downloads.bbc.co.uk/podcasts/worldservice/xtra/xtra_20080903-1217a.mp3";);
+	fail_unless (entry != NULL, "entry not upgraded");
+	fail_unless (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_MOUNTPOINT) == NULL, "wrong mountpoint for podcast");
+}
+END_TEST
 
 static Suite *
 rhythmdb_suite (void)
@@ -432,6 +456,7 @@
 	/*tcase_add_test (tc_chain, test_rhythmdb_serialisation);*/
 
 	/* tests for breakable bug fixes */
+	tcase_add_test (tc_chain, test_rhythmdb_podcast_upgrade);
 
 	return s;
 }
@@ -448,7 +473,6 @@
 
 	g_thread_init (NULL);
 	rb_threads_init ();
-	gtk_set_locale ();
 	gtk_init (&argc, &argv);
 	rb_debug_init (TRUE);
 	rb_refstring_system_init ();



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