[rygel-gst-0-10-plugins] Cleanup RygelMediaExportMediaCacheUpgrader.



commit 195cf19f65bb2a2c2635957619080d4ddf62fc85
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Thu Jan 31 13:44:44 2013 +0100

    Cleanup RygelMediaExportMediaCacheUpgrader.

 .../rygel-media-export-media-cache-upgrader.c      | 2844 +++++++-------------
 1 files changed, 963 insertions(+), 1881 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-media-cache-upgrader.c b/src/media-export/rygel-media-export-media-cache-upgrader.c
index c94ab79..0b971e6 100644
--- a/src/media-export/rygel-media-export-media-cache-upgrader.c
+++ b/src/media-export/rygel-media-export-media-cache-upgrader.c
@@ -33,1942 +33,1024 @@
 G_DEFINE_TYPE (RygelMediaExportMediaCacheUpgrader, rygel_media_export_media_cache_upgrader, G_TYPE_OBJECT)
 
 struct _RygelMediaExportMediaCacheUpgraderPrivate {
-	RygelMediaExportDatabase* database;
-	RygelMediaExportSQLFactory* sql;
+  RygelMediaExportDatabase* database;
+  RygelMediaExportSQLFactory* sql;
 };
 
 #define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderPrivate))
 enum  {
-	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DUMMY_PROPERTY
+  RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DUMMY_PROPERTY,
+  RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DATABASE,
+  RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_SQL_FACTORY
 };
-#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_2 "UPDATE meta_data SET object_fk = " "(SELECT upnp_id FROM Object WHERE metadata_fk = meta_data.id)"
+
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_2 "UPDATE meta_data SET object_fk = (SELECT upnp_id FROM Object WHERE metadata_fk = meta_data.id)"
 #define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_3 "ALTER TABLE Object ADD timestamp INTEGER"
 #define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_4 "UPDATE Object SET timestamp = 0"
-static void rygel_media_export_media_cache_upgrader_update_v3_v4 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v4_v5 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v5_v6 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v6_v7 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v7_v8 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v8_v9 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v9_v10 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_update_v10_v11 (RygelMediaExportMediaCacheUpgrader* self);
-static void rygel_media_export_media_cache_upgrader_force_reindex (RygelMediaExportMediaCacheUpgrader* self, GError** error);
-static void _vala_GValue_array_free (GValue* array, gint array_length);
-
-
-RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_construct (GType object_type, RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql) {
-	RygelMediaExportMediaCacheUpgrader* self = NULL;
-	RygelMediaExportDatabase* _tmp0_;
-	RygelMediaExportSQLFactory* _tmp1_;
-	g_return_val_if_fail (database != NULL, NULL);
-	g_return_val_if_fail (sql != NULL, NULL);
-	self = (RygelMediaExportMediaCacheUpgrader*) g_type_create_instance (object_type);
-	_tmp0_ = database;
-	self->priv->database = _tmp0_;
-	_tmp1_ = sql;
-	self->priv->sql = _tmp1_;
-	return self;
-}
 
+RygelMediaExportMediaCacheUpgrader *
+rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase   *database,
+					     RygelMediaExportSQLFactory *sql) {
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_DATABASE (database), NULL);
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY (sql), NULL);
 
-RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql) {
-	return rygel_media_export_media_cache_upgrader_construct (RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, database, sql);
+  return RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER (g_object_new (RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER,
+								"database", database,
+								"sql-factory", sql,
+								NULL));
 }
 
+gboolean
+rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader  *self,
+                                                       gint                                *current_version,
+                                                       GError                             **error) {
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+  gint version;
+  GError *inner_error;
+
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self), FALSE);
 
-gboolean rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint* current_version, GError** error) {
-	gint _vala_current_version = 0;
-	gboolean result = FALSE;
-	RygelMediaExportDatabase* _tmp0_;
-	gint _tmp1_ = 0;
-	gint _tmp2_;
-	gint _tmp3_;
-	gint _tmp4_ = 0;
-	GError * _inner_error_ = NULL;
-	g_return_val_if_fail (self != NULL, FALSE);
-	_tmp0_ = self->priv->database;
-	_tmp1_ = rygel_media_export_database_query_value (_tmp0_, "SELECT version FROM schema_info", NULL, 0, &_inner_error_);
-	_tmp2_ = _tmp1_;
-	if (_inner_error_ != NULL) {
-		g_propagate_error (error, _inner_error_);
-		return FALSE;
-	}
-	_vala_current_version = _tmp2_;
-	_tmp3_ = _vala_current_version;
-	_tmp4_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
-	result = _tmp3_ < _tmp4_;
-	if (current_version) {
-		*current_version = _vala_current_version;
-	}
-	return result;
+  priv = self->priv;
+  inner_error = NULL;
+  version = rygel_media_export_database_query_value (priv->database, "SELECT version FROM schema_info", NULL, 0, &inner_error);
+  if (inner_error) {
+    g_propagate_error (error, inner_error);
+    return FALSE;
+  }
+  if (current_version) {
+    *current_version = version;
+  }
+  return (version < atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION));
 }
 
+void
+rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader  *self,
+						    GError                             **error) {
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+  gint matching_schema_count;
+  GError *inner_error;
 
-void rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader* self, GError** error) {
-	RygelMediaExportDatabase* _tmp0_;
-	gint _tmp1_ = 0;
-	gint matching_schema_count;
-	gint _tmp2_;
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	_tmp0_ = self->priv->database;
-	_tmp1_ = rygel_media_export_database_query_value (_tmp0_, "SELECT count(*) FROM " "sqlite_master WHERE sql " "LIKE 'CREATE TABLE Meta_Data" "%object_fk TEXT UNIQUE%'", NULL, 0, &_inner_error_);
-	matching_schema_count = _tmp1_;
-	if (_inner_error_ != NULL) {
-		g_propagate_error (error, _inner_error_);
-		return;
-	}
-	_tmp2_ = matching_schema_count;
-	if (_tmp2_ == 0) {
-		{
-			RygelMediaExportDatabase* _tmp3_;
-			RygelMediaExportDatabase* _tmp4_;
-			RygelMediaExportDatabase* _tmp5_;
-			RygelMediaExportDatabase* _tmp6_;
-			RygelMediaExportSQLFactory* _tmp7_;
-			const gchar* _tmp8_ = NULL;
-			RygelMediaExportDatabase* _tmp9_;
-			g_message ("rygel-media-export-media-cache-upgrader.vala:58: Found faulty schema, " \
-"forcing full reindex");
-			_tmp3_ = self->priv->database;
-			rygel_media_export_database_begin (_tmp3_, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				goto __catch12_g_error;
-			}
-			_tmp4_ = self->priv->database;
-			rygel_media_export_database_exec (_tmp4_, "DELETE FROM Object WHERE upnp_id IN (" "SELECT DISTINCT object_fk FROM meta_data)", NULL, 0, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				goto __catch12_g_error;
-			}
-			_tmp5_ = self->priv->database;
-			rygel_media_export_database_exec (_tmp5_, "DROP TABLE Meta_Data", NULL, 0, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				goto __catch12_g_error;
-			}
-			_tmp6_ = self->priv->database;
-			_tmp7_ = self->priv->sql;
-			_tmp8_ = rygel_media_export_sql_factory_make (_tmp7_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA);
-			rygel_media_export_database_exec (_tmp6_, _tmp8_, NULL, 0, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				goto __catch12_g_error;
-			}
-			_tmp9_ = self->priv->database;
-			rygel_media_export_database_commit (_tmp9_, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				goto __catch12_g_error;
-			}
-		}
-		goto __finally12;
-		__catch12_g_error:
-		{
-			GError* _error_ = NULL;
-			RygelMediaExportDatabase* _tmp10_;
-			GError* _tmp11_;
-			const gchar* _tmp12_;
-			gchar* _tmp13_;
-			gchar* _tmp14_;
-			_error_ = _inner_error_;
-			_inner_error_ = NULL;
-			_tmp10_ = self->priv->database;
-			rygel_media_export_database_rollback (_tmp10_);
-			_tmp11_ = _error_;
-			_tmp12_ = _tmp11_->message;
-			_tmp13_ = g_strconcat ("Failed to force reindex to fix database: ", _tmp12_, NULL);
-			_tmp14_ = _tmp13_;
-			g_warning ("rygel-media-export-media-cache-upgrader.vala:67: %s", _tmp14_);
-			g_free (_tmp14_);
-			g_error_free (_error_);
-		}
-		__finally12:
-		if (_inner_error_ != NULL) {
-			g_propagate_error (error, _inner_error_);
-			return;
-		}
-	}
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  priv = self->priv;
+  inner_error = NULL;
+  matching_schema_count = rygel_media_export_database_query_value (priv->database,
+								   "SELECT count(*) FROM sqlite_master WHERE sql LIKE 'CREATE TABLE Meta_Data%object_fk TEXT UNIQUE%'",
+								   NULL,
+								   0,
+								   &inner_error);
+  if (inner_error) {
+    g_propagate_error (error, inner_error);
+    return;
+  }
+  if (!matching_schema_count) {
+    g_message ("Found faulty schema, forcing full reindex");
+    rygel_media_export_database_begin (priv->database, &inner_error);
+    if (inner_error) {
+      goto out;
+    }
+    rygel_media_export_database_exec (priv->database,
+				      "DELETE FROM Object WHERE upnp_id IN (SELECT DISTINCT object_fk FROM meta_data)",
+				      NULL,
+				      0,
+				      &inner_error);
+    if (inner_error) {
+      goto out;
+    }
+    rygel_media_export_database_exec (priv->database,
+				      "DROP TABLE Meta_Data",
+				      NULL,
+				      0,
+				      &inner_error);
+    if (inner_error) {
+      goto out;
+    }
+    rygel_media_export_database_exec (priv->database,
+				      rygel_media_export_sql_factory_make (priv->sql,
+									   RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA),
+				      NULL,
+				      0,
+				      &inner_error);
+    if (inner_error) {
+      goto out;
+    }
+    rygel_media_export_database_commit (priv->database, &inner_error);
+    if (inner_error) {
+      goto out;
+    }
+  out:
+    if (inner_error) {
+      rygel_media_export_database_rollback (priv->database);
+      g_warning ("Failed to force reindex to fix database: %s", inner_error->message);
+      g_error_free (inner_error);
+      inner_error = NULL;
+    }
+  }
+  if (inner_error) {
+    g_propagate_error (error, inner_error);
+    return;
+  }
 }
 
+void
+rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
 
-void rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportSQLFactory* _tmp1_;
-		const gchar* _tmp2_ = NULL;
-		RygelMediaExportDatabase* _tmp3_;
-		_tmp0_ = self->priv->database;
-		_tmp1_ = self->priv->sql;
-		_tmp2_ = rygel_media_export_sql_factory_make (_tmp1_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
-		rygel_media_export_database_exec (_tmp0_, _tmp2_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			goto __catch13_g_error;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp3_);
-	}
-	goto __finally13;
-	__catch13_g_error:
-	{
-		GError* _error_ = NULL;
-		GError* _tmp4_;
-		const gchar* _tmp5_;
-		gchar* _tmp6_;
-		gchar* _tmp7_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp4_ = _error_;
-		_tmp5_ = _tmp4_->message;
-		_tmp6_ = g_strconcat ("Failed to create indices: ", _tmp5_, NULL);
-		_tmp7_ = _tmp6_;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:78: %s", _tmp7_);
-		g_free (_tmp7_);
-		g_error_free (_error_);
-	}
-	__finally13:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  inner_error = NULL;
+  priv = self->priv;
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    g_warning ("Failed to create indices: %s", inner_error->message);
+    g_error_free (inner_error);
+    return;
+  }
+  rygel_media_export_database_analyze (priv->database);
 }
 
+static void
+rygel_media_export_media_cache_upgrader_force_reindex (RygelMediaExportMediaCacheUpgrader  *self,
+						       GError                            **error) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
 
-void rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint old_version) {
-	gint _tmp0_ = 0;
-	gint current_version;
-	g_return_if_fail (self != NULL);
-	g_debug ("rygel-media-export-media-cache-upgrader.vala:84: Older schema detected" \
-". Upgrading...");
-	_tmp0_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
-	current_version = _tmp0_;
-	while (TRUE) {
-		gint _tmp1_;
-		gint _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		_tmp1_ = old_version;
-		_tmp2_ = current_version;
-		if (!(_tmp1_ < _tmp2_)) {
-			break;
-		}
-		_tmp3_ = self->priv->database;
-		if (_tmp3_ != NULL) {
-			gint _tmp4_;
-			gint _tmp5_;
-			_tmp4_ = old_version;
-			switch (_tmp4_) {
-				case 3:
-				{
-					rygel_media_export_media_cache_upgrader_update_v3_v4 (self);
-					break;
-				}
-				case 4:
-				{
-					rygel_media_export_media_cache_upgrader_update_v4_v5 (self);
-					break;
-				}
-				case 5:
-				{
-					rygel_media_export_media_cache_upgrader_update_v5_v6 (self);
-					break;
-				}
-				case 6:
-				{
-					rygel_media_export_media_cache_upgrader_update_v6_v7 (self);
-					break;
-				}
-				case 7:
-				{
-					rygel_media_export_media_cache_upgrader_update_v7_v8 (self);
-					break;
-				}
-				case 8:
-				{
-					rygel_media_export_media_cache_upgrader_update_v8_v9 (self);
-					break;
-				}
-				case 9:
-				{
-					rygel_media_export_media_cache_upgrader_update_v9_v10 (self);
-					break;
-				}
-				case 10:
-				{
-					rygel_media_export_media_cache_upgrader_update_v10_v11 (self);
-					break;
-				}
-				default:
-				{
-					g_warning ("rygel-media-export-media-cache-upgrader.vala:114: Cannot upgrade");
-					self->priv->database = NULL;
-					break;
-				}
-			}
-			_tmp5_ = old_version;
-			old_version = _tmp5_ + 1;
-		}
-	}
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  priv = self->priv;
+  inner_error = NULL;
+  rygel_media_export_database_exec (priv->database,
+				    "UPDATE Object SET timestamp = 0",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    g_propagate_error (error, inner_error);
+    return;
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v3_v4 (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
 
-static void rygel_media_export_media_cache_upgrader_force_reindex (RygelMediaExportMediaCacheUpgrader* self, GError** error) {
-	RygelMediaExportDatabase* _tmp0_;
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	_tmp0_ = self->priv->database;
-	rygel_media_export_database_exec (_tmp0_, "UPDATE Object SET timestamp = 0", NULL, 0, &_inner_error_);
-	if (_inner_error_ != NULL) {
-		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-			g_propagate_error (error, _inner_error_);
-			return;
-		} else {
-			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-	}
+  priv = self->priv;
+  inner_error = NULL;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    "ALTER TABLE Meta_Data RENAME TO _Meta_Data",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    "INSERT INTO meta_data (size, mime_type, duration, width, height, class, author, album, date, bitrate, "
+				    "sample_freq, bits_per_sample, channels, track, color_depth, object_fk) SELECT size, mime_type, duration, "
+				    "width, height, class, author, album, date, bitrate, sample_freq, bits_per_sample, channels, track, "
+				    "color_depth, o.upnp_id FROM _Meta_Data JOIN object o ON id = o.metadata_fk",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TABLE _Meta_Data", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_3, NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_4, NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '4'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v4_v5 (RygelMediaExportMediaCacheUpgrader *self) {
+  GeeQueue* queue;
+  GeeCollection *collection;
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  queue = NULL;
+  inner_error = NULL;
+  priv = self->priv;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER IF EXISTS trgr_delete_children", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DELETE FROM Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    "INSERT INTO _Object (upnp_id, type_fk, title, timestamp) VALUES ('0', 0, 'Root', 0)",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    "INSERT INTO Object (upnp_id, type_fk, title, timestamp) VALUES ('0', 0, 'Root', 0)",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+
+  queue = GEE_QUEUE (gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL));
+  collection = GEE_COLLECTION (queue);
+  gee_queue_offer (queue, "0");
+  while (!gee_collection_get_is_empty (collection)) {
+    GValue value = G_VALUE_INIT;
+    RygelMediaExportDatabaseCursor *cursor;
 
-static void rygel_media_export_media_cache_upgrader_update_v3_v4 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportSQLFactory* _tmp3_;
-		const gchar* _tmp4_ = NULL;
-		RygelMediaExportDatabase* _tmp5_;
-		RygelMediaExportDatabase* _tmp6_;
-		RygelMediaExportDatabase* _tmp7_;
-		RygelMediaExportDatabase* _tmp8_;
-		RygelMediaExportDatabase* _tmp9_;
-		RygelMediaExportSQLFactory* _tmp10_;
-		const gchar* _tmp11_ = NULL;
-		RygelMediaExportDatabase* _tmp12_;
-		RygelMediaExportDatabase* _tmp13_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "ALTER TABLE Meta_Data RENAME TO _Meta_Data", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		_tmp3_ = self->priv->sql;
-		_tmp4_ = rygel_media_export_sql_factory_make (_tmp3_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA);
-		rygel_media_export_database_exec (_tmp2_, _tmp4_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp5_, "INSERT INTO meta_data (size, mime_type, " "duration, width, height, class, author, album, " "date, bitrate, sample_freq, bits_per_sample, " "channels, track, color_depth, object_fk) SELECT " "size, mime_type, duration, width, height, class, " "author, album, date, bitrate, sample_freq, " "bits_per_sample, channels, track, color_depth, " "o.upnp_id FROM _Meta_Data JOIN object o " "ON id = o.metadata_fk", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp6_, "DROP TABLE _Meta_Data", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp7_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_3, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp8_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp8_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_4, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp9_ = self->priv->database;
-		_tmp10_ = self->priv->sql;
-		_tmp11_ = rygel_media_export_sql_factory_make (_tmp10_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
-		rygel_media_export_database_exec (_tmp9_, _tmp11_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp12_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp12_, "UPDATE schema_info SET version = '4'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp13_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp13_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch14_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-	}
-	goto __finally14;
-	__catch14_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp14_;
-		GError* _tmp15_;
-		const gchar* _tmp16_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp14_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp14_);
-		_tmp15_ = _error_;
-		_tmp16_ = _tmp15_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:149: Database upgrade fai" \
-"led: %s", _tmp16_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally14:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+    g_value_init (&value, G_TYPE_STRING);
+    g_value_take_string (&value, gee_queue_poll (queue));
+
+    cursor = rygel_media_export_database_exec_cursor (priv->database,
+						      "SELECT upnp_id FROM _Object WHERE parent = ?",
+						      &value,
+						      1,
+						      &inner_error);
+    if (inner_error) {
+      g_value_unset (&value);
+      goto out;
+    }
+
+    while (rygel_media_export_database_cursor_has_next (cursor)) {
+      sqlite3_stmt *stmt = rygel_media_export_database_cursor_next (cursor, &inner_error);
+
+      if (inner_error) {
+	g_value_unset (&value);
+	goto out;
+      }
+      gee_queue_offer (queue, sqlite3_column_text (stmt, 0));
+    }
+    g_object_unref (cursor);
+    rygel_media_export_database_exec (priv->database,
+				      "INSERT INTO Object SELECT * FROM _OBJECT WHERE parent = ?",
+				      &value,
+				      1,
+				      &inner_error);
+    g_value_unset (&value);
+    if (inner_error) {
+      goto out;
+    }
+  }
+  g_object_unref (queue);
+  queue = NULL;
+  rygel_media_export_database_exec (priv->database, "DROP TABLE Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '5'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+    if (queue) {
+        g_object_unref (queue);
+    }
+  }
 }
 
+static void rygel_media_export_media_cache_upgrader_update_v5_v6 (RygelMediaExportMediaCacheUpgrader* self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
 
-static void _vala_GValue_array_free (GValue* array, gint array_length) {
-	if (array != NULL) {
-		int i;
-		for (i = 0; i < array_length; i = i + 1) {
-			g_value_unset (&array[i]);
-		}
-	}
-	g_free (array);
+  priv = self->priv;
+  inner_error = NULL;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TABLE object_type", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER IF EXISTS trgr_delete_uris", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE Object ADD COLUMN uri TEXT", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE Object SET uri = (SELECT uri FROM uri WHERE Uri.object_fk == Object.upnp_id LIMIT 1)", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP INDEX IF EXISTS idx_uri_fk", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TABLE Uri", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '6'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
 
-static void rygel_media_export_media_cache_upgrader_update_v4_v5 (RygelMediaExportMediaCacheUpgrader* self) {
-	GeeLinkedList* _tmp0_;
-	GeeQueue* queue;
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	_tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
-	queue = (GeeQueue*) _tmp0_;
-	{
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportSQLFactory* _tmp4_;
-		const gchar* _tmp5_ = NULL;
-		RygelMediaExportDatabase* _tmp6_;
-		RygelMediaExportDatabase* _tmp7_;
-		RygelMediaExportDatabase* _tmp8_;
-		RygelMediaExportDatabase* _tmp9_;
-		RygelMediaExportSQLFactory* _tmp10_;
-		const gchar* _tmp11_ = NULL;
-		RygelMediaExportDatabase* _tmp12_;
-		RygelMediaExportDatabase* _tmp13_;
-		GeeQueue* _tmp14_;
-		RygelMediaExportDatabase* _tmp36_;
-		RygelMediaExportDatabase* _tmp37_;
-		RygelMediaExportDatabase* _tmp38_;
-		RygelMediaExportSQLFactory* _tmp39_;
-		const gchar* _tmp40_ = NULL;
-		RygelMediaExportDatabase* _tmp41_;
-		RygelMediaExportSQLFactory* _tmp42_;
-		const gchar* _tmp43_ = NULL;
-		RygelMediaExportDatabase* _tmp44_;
-		RygelMediaExportDatabase* _tmp45_;
-		RygelMediaExportDatabase* _tmp46_;
-		RygelMediaExportDatabase* _tmp47_;
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp1_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER IF EXISTS trgr_delete_children", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		_tmp4_ = self->priv->sql;
-		_tmp5_ = rygel_media_export_sql_factory_make (_tmp4_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
-		rygel_media_export_database_exec (_tmp3_, _tmp5_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp6_, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp7_, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp8_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp8_, "DELETE FROM Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp9_ = self->priv->database;
-		_tmp10_ = self->priv->sql;
-		_tmp11_ = rygel_media_export_sql_factory_make (_tmp10_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
-		rygel_media_export_database_exec (_tmp9_, _tmp11_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp12_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp12_, "INSERT INTO _Object (upnp_id, type_fk, title, " "timestamp) VALUES ('0', 0, 'Root', 0)", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp13_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp13_, "INSERT INTO Object (upnp_id, type_fk, title, " "timestamp) VALUES ('0', 0, 'Root', 0)", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp14_ = queue;
-		gee_queue_offer (_tmp14_, "0");
-		while (TRUE) {
-			GeeQueue* _tmp15_;
-			gboolean _tmp16_;
-			gboolean _tmp17_;
-			GeeQueue* _tmp18_;
-			gpointer _tmp19_ = NULL;
-			GValue _tmp20_ = {0};
-			GValue* _tmp21_ = NULL;
-			GValue* args;
-			gint args_length1;
-			RygelMediaExportDatabase* _tmp22_;
-			GValue* _tmp23_;
-			gint _tmp23__length1;
-			RygelMediaExportDatabaseCursor* _tmp24_ = NULL;
-			RygelMediaExportDatabaseCursor* cursor;
-			RygelMediaExportDatabase* _tmp34_;
-			GValue* _tmp35_;
-			gint _tmp35__length1;
-			_tmp15_ = queue;
-			_tmp16_ = gee_collection_get_is_empty ((GeeCollection*) _tmp15_);
-			_tmp17_ = _tmp16_;
-			if (!(!_tmp17_)) {
-				break;
-			}
-			_tmp18_ = queue;
-			_tmp19_ = gee_queue_poll (_tmp18_);
-			g_value_init (&_tmp20_, G_TYPE_STRING);
-			g_value_take_string (&_tmp20_, (gchar*) _tmp19_);
-			_tmp21_ = g_new0 (GValue, 1);
-			_tmp21_[0] = _tmp20_;
-			args = _tmp21_;
-			args_length1 = 1;
-			_tmp22_ = self->priv->database;
-			_tmp23_ = args;
-			_tmp23__length1 = args_length1;
-			_tmp24_ = rygel_media_export_database_exec_cursor (_tmp22_, "SELECT upnp_id FROM _Object WHERE " "parent = ?", _tmp23_, _tmp23__length1, &_inner_error_);
-			cursor = _tmp24_;
-			if (_inner_error_ != NULL) {
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-					goto __catch15_rygel_media_export_database_error;
-				}
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-				g_clear_error (&_inner_error_);
-				return;
-			}
-			{
-				while (TRUE) {
-					gboolean _tmp28_ = FALSE;
-					sqlite3_stmt* _tmp30_ = NULL;
-					sqlite3_stmt* statement;
-					GeeQueue* _tmp31_;
-					sqlite3_stmt* _tmp32_;
-					const gchar* _tmp33_ = NULL;
-					_tmp28_ = rygel_media_export_database_cursor_has_next (cursor);
-					if (!_tmp28_) {
-						break;
-					}
-					_tmp30_ = rygel_media_export_database_cursor_next (cursor, &_inner_error_);
-					statement = _tmp30_;
-					if (_inner_error_ != NULL) {
-						g_object_unref (cursor);
-						args = (_vala_GValue_array_free (args, args_length1), NULL);
-						if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-							goto __catch15_rygel_media_export_database_error;
-						}
-						g_object_unref (cursor);
-						args = (_vala_GValue_array_free (args, args_length1), NULL);
-						g_object_unref (queue);
-						g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-						g_clear_error (&_inner_error_);
-						return;
-					}
-					_tmp31_ = queue;
-					_tmp32_ = statement;
-					_tmp33_ = (const gchar *) sqlite3_column_text (_tmp32_, 0);
-					gee_queue_offer (_tmp31_, _tmp33_);
-				}
-			}
-			_tmp34_ = self->priv->database;
-			_tmp35_ = args;
-			_tmp35__length1 = args_length1;
-			rygel_media_export_database_exec (_tmp34_, "INSERT INTO Object SELECT * FROM _OBJECT " "WHERE parent = ?", _tmp35_, _tmp35__length1, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				g_object_unref (cursor);
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-					goto __catch15_rygel_media_export_database_error;
-				}
-				g_object_unref (cursor);
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-				g_clear_error (&_inner_error_);
-				return;
-			}
-			g_object_unref (cursor);
-			args = (_vala_GValue_array_free (args, args_length1), NULL);
-		}
-		_tmp36_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp36_, "DROP TABLE Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp37_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp37_, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp38_ = self->priv->database;
-		_tmp39_ = self->priv->sql;
-		_tmp40_ = rygel_media_export_sql_factory_make (_tmp39_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
-		rygel_media_export_database_exec (_tmp38_, _tmp40_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp41_ = self->priv->database;
-		_tmp42_ = self->priv->sql;
-		_tmp43_ = rygel_media_export_sql_factory_make (_tmp42_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
-		rygel_media_export_database_exec (_tmp41_, _tmp43_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp44_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp44_, "UPDATE schema_info SET version = '5'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp45_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp45_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp46_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp46_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch15_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp47_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp47_);
-	}
-	goto __finally15;
-	__catch15_rygel_media_export_database_error:
-	{
-		GError* err = NULL;
-		RygelMediaExportDatabase* _tmp48_;
-		GError* _tmp49_;
-		const gchar* _tmp50_;
-		err = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp48_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp48_);
-		_tmp49_ = err;
-		_tmp50_ = _tmp49_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:197: Database upgrade fai" \
-"led: %s", _tmp50_);
-		self->priv->database = NULL;
-		g_error_free (err);
-	}
-	__finally15:
-	if (_inner_error_ != NULL) {
-		g_object_unref (queue);
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
-	g_object_unref (queue);
+static void
+rygel_media_export_media_cache_upgrader_update_v6_v7 (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER (self));
+
+  inner_error = NULL;
+  priv = self->priv;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE meta_data ADD COLUMN dlna_profile TEXT", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '7'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_media_cache_upgrader_force_reindex (self, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v7_v8 (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
 
-static void rygel_media_export_media_cache_upgrader_update_v5_v6 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportDatabase* _tmp5_;
-		RygelMediaExportDatabase* _tmp6_;
-		RygelMediaExportDatabase* _tmp7_;
-		RygelMediaExportDatabase* _tmp8_;
-		RygelMediaExportDatabase* _tmp9_;
-		RygelMediaExportDatabase* _tmp10_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "DROP TABLE object_type", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER IF EXISTS trgr_delete_uris", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp3_, "ALTER TABLE Object ADD COLUMN uri TEXT", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp4_, "UPDATE Object SET uri = (SELECT uri " "FROM uri WHERE Uri.object_fk == Object.upnp_id LIMIT 1)", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp5_, "DROP INDEX IF EXISTS idx_uri_fk", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp6_, "DROP TABLE Uri", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp7_, "UPDATE schema_info SET version = '6'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp8_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp8_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp9_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp9_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch16_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp10_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp10_);
-	}
-	goto __finally16;
-	__catch16_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp11_;
-		GError* _tmp12_;
-		const gchar* _tmp13_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp11_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp11_);
-		_tmp12_ = _error_;
-		_tmp13_ = _tmp12_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:218: Database upgrade fai" \
-"led: %s", _tmp13_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally16:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER (self));
+
+  priv = self->priv;
+  inner_error = NULL;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE object ADD COLUMN flags TEXT", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE meta_data ADD COLUMN genre TEXT", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '8'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_media_cache_upgrader_force_reindex (self, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v8_v9 (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
 
-static void rygel_media_export_media_cache_upgrader_update_v6_v7 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportDatabase* _tmp5_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "ALTER TABLE meta_data ADD COLUMN dlna_profile TEXT", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "UPDATE schema_info SET version = '7'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		rygel_media_export_media_cache_upgrader_force_reindex (self, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp3_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp4_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch17_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp5_);
-	}
-	goto __finally17;
-	__catch17_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp6_;
-		GError* _tmp7_;
-		const gchar* _tmp8_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp6_);
-		_tmp7_ = _error_;
-		_tmp8_ = _tmp7_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:234: Database upgrade fai" \
-"led: %s", _tmp8_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally17:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  inner_error = NULL;
+  priv = self->priv;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER trgr_update_closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER trgr_delete_closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE Closure RENAME TO _Closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "INSERT INTO Closure (ancestor, descendant, depth) SELECT DISTINCT ancestor, descendant, depth FROM _Closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TABLE _Closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '9'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v9_v10 (RygelMediaExportMediaCacheUpgrader *self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+  GeeQueue *queue;
+  GeeCollection *collection;
+  gchar *sql_string;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  queue = NULL;
+  priv = self->priv;
+  inner_error = NULL;
+
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DELETE FROM Object WHERE upnp_id LIKE '" RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "%'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER trgr_update_closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER trgr_delete_closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP INDEX idx_parent", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP INDEX idx_meta_data_fk", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP INDEX IF EXISTS idx_closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TABLE Closure", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DROP TRIGGER trgr_delete_metadata", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  sql_string = g_strconcat ("INSERT OR REPLACE INTO Object (parent, upnp_id, type_fk, title, timestamp) VALUES ('0', '"
+			    RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID
+			    "', 0, '",
+			    _(RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME),
+			    "', 0)",
+			    NULL);
+  rygel_media_export_database_exec (priv->database, sql_string, NULL, 0, &inner_error);
+  g_free (sql_string);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    "UPDATE Object SET parent = '"
+				    RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID
+				    "' WHERE parent = '0' AND upnp_id NOT LIKE 'virtual-%' AND upnp_id <> '"
+				    RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID
+				    "'",
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "DELETE FROM Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "INSERT INTO Closure (ancestor, descendant, depth) VALUES ('0','0',0)", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+
+  queue = GEE_QUEUE (gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL));
+  collection = GEE_COLLECTION (queue);
 
-static void rygel_media_export_media_cache_upgrader_update_v7_v8 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportDatabase* _tmp5_;
-		RygelMediaExportDatabase* _tmp6_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "ALTER TABLE object ADD COLUMN flags TEXT", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "ALTER TABLE meta_data ADD COLUMN genre TEXT", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp3_, "UPDATE schema_info SET version = '8'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		rygel_media_export_media_cache_upgrader_force_reindex (self, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp4_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp5_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch18_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp6_);
-	}
-	goto __finally18;
-	__catch18_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp7_;
-		GError* _tmp8_;
-		const gchar* _tmp9_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp7_);
-		_tmp8_ = _error_;
-		_tmp9_ = _tmp8_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:251: Database upgrade fai" \
-"led: %s", _tmp9_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally18:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  gee_queue_offer (queue, "0");
+  while (!gee_collection_get_is_empty (collection)) {
+    GValue value = G_VALUE_INIT;
+    RygelMediaExportDatabaseCursor *cursor;
+
+    g_value_init (&value, G_TYPE_STRING);
+    g_value_take_string (&value, gee_queue_poll (queue));
+    cursor = rygel_media_export_database_exec_cursor (priv->database, "SELECT upnp_id FROM _Object WHERE parent = ?", &value, 1, &inner_error);
+    if (inner_error) {
+      g_value_unset (&value);
+      goto out;
+    }
+    while (rygel_media_export_database_cursor_has_next (cursor)) {
+      sqlite3_stmt* statement = rygel_media_export_database_cursor_next (cursor, &inner_error);
+
+      if (inner_error) {
+	g_object_unref (cursor);
+	g_value_unset (&value);
+	goto out;
+      }
+      gee_queue_offer (queue, sqlite3_column_text (statement, 0));
+    }
+    g_object_unref (cursor);
+    rygel_media_export_database_exec (priv->database,
+				      "INSERT INTO Object SELECT * FROM _Object WHERE parent = ?",
+				      &value,
+				      1,
+				      &inner_error);
+    g_value_unset (&value);
+    if (inner_error) {
+      goto out;
+    }
+  }
+  g_object_unref (queue);
+  queue = NULL;
+  rygel_media_export_database_exec (priv->database, "DROP TABLE Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database,
+				    rygel_media_export_sql_factory_make (priv->sql,
+									 RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE),
+				    NULL,
+				    0,
+				    &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '10'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+    if (queue) {
+      g_object_unref (queue);
+    }
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_update_v10_v11 (RygelMediaExportMediaCacheUpgrader* self) {
+  GError *inner_error;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
 
-static void rygel_media_export_media_cache_upgrader_update_v8_v9 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportSQLFactory* _tmp5_;
-		const gchar* _tmp6_ = NULL;
-		RygelMediaExportDatabase* _tmp7_;
-		RygelMediaExportDatabase* _tmp8_;
-		RygelMediaExportSQLFactory* _tmp9_;
-		const gchar* _tmp10_ = NULL;
-		RygelMediaExportDatabase* _tmp11_;
-		RygelMediaExportDatabase* _tmp12_;
-		RygelMediaExportDatabase* _tmp13_;
-		RygelMediaExportDatabase* _tmp14_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "DROP TRIGGER trgr_update_closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER trgr_delete_closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp3_, "ALTER TABLE Closure RENAME TO _Closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		_tmp5_ = self->priv->sql;
-		_tmp6_ = rygel_media_export_sql_factory_make (_tmp5_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
-		rygel_media_export_database_exec (_tmp4_, _tmp6_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp7_, "INSERT INTO Closure (ancestor, " "descendant, depth) SELECT DISTINCT " "ancestor, descendant, depth FROM " "_Closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp8_ = self->priv->database;
-		_tmp9_ = self->priv->sql;
-		_tmp10_ = rygel_media_export_sql_factory_make (_tmp9_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
-		rygel_media_export_database_exec (_tmp8_, _tmp10_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp11_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp11_, "DROP TABLE _Closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp12_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp12_, "UPDATE schema_info SET version = '9'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp13_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp13_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp14_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp14_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch19_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-	}
-	goto __finally19;
-	__catch19_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp15_;
-		GError* _tmp16_;
-		const gchar* _tmp17_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp15_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp15_);
-		_tmp16_ = _error_;
-		_tmp17_ = _tmp16_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:274: Database upgrade fai" \
-"led: %s", _tmp17_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally19:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
+
+  inner_error = NULL;
+  priv = self->priv;
+  rygel_media_export_database_begin (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "ALTER TABLE Meta_Data    ADD COLUMN disc INTEGER", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE Object SET timestamp = 0 WHERE   upnp_id IN (SELECT object_fk FROM Meta_Data WHERE   class LIKE 'object.item.audioItem.%')", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "UPDATE schema_info SET version = '11'", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_commit (priv->database, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_exec (priv->database, "VACUUM", NULL, 0, &inner_error);
+  if (inner_error) {
+    goto out;
+  }
+  rygel_media_export_database_analyze (priv->database);
+ out:
+  if (inner_error) {
+    rygel_media_export_database_rollback (priv->database);
+    g_warning ("Database upgrade failed: %s", inner_error->message);
+    priv->database = NULL;
+    g_error_free (inner_error);
+  }
 }
 
+void
+rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader *self,
+						 gint                                old_version) {
+  gint current_version;
+  RygelMediaExportMediaCacheUpgraderPrivate *priv;
+
+  g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER (self));
 
-static void rygel_media_export_media_cache_upgrader_update_v9_v10 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		GeeLinkedList* _tmp0_;
-		GeeLinkedList* queue;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportDatabase* _tmp5_;
-		RygelMediaExportDatabase* _tmp6_;
-		RygelMediaExportDatabase* _tmp7_;
-		RygelMediaExportDatabase* _tmp8_;
-		RygelMediaExportDatabase* _tmp9_;
-		RygelMediaExportDatabase* _tmp10_;
-		const gchar* _tmp11_ = NULL;
-		gchar* _tmp12_;
-		gchar* _tmp13_;
-		gchar* _tmp14_;
-		gchar* _tmp15_;
-		RygelMediaExportDatabase* _tmp16_;
-		RygelMediaExportDatabase* _tmp17_;
-		RygelMediaExportDatabase* _tmp18_;
-		RygelMediaExportDatabase* _tmp19_;
-		RygelMediaExportDatabase* _tmp20_;
-		RygelMediaExportSQLFactory* _tmp21_;
-		const gchar* _tmp22_ = NULL;
-		RygelMediaExportDatabase* _tmp23_;
-		RygelMediaExportSQLFactory* _tmp24_;
-		const gchar* _tmp25_ = NULL;
-		RygelMediaExportDatabase* _tmp26_;
-		GeeLinkedList* _tmp27_;
-		RygelMediaExportDatabase* _tmp49_;
-		RygelMediaExportDatabase* _tmp50_;
-		RygelMediaExportDatabase* _tmp51_;
-		RygelMediaExportSQLFactory* _tmp52_;
-		const gchar* _tmp53_ = NULL;
-		RygelMediaExportDatabase* _tmp54_;
-		RygelMediaExportSQLFactory* _tmp55_;
-		const gchar* _tmp56_ = NULL;
-		RygelMediaExportDatabase* _tmp57_;
-		RygelMediaExportSQLFactory* _tmp58_;
-		const gchar* _tmp59_ = NULL;
-		RygelMediaExportDatabase* _tmp60_;
-		RygelMediaExportDatabase* _tmp61_;
-		RygelMediaExportDatabase* _tmp62_;
-		RygelMediaExportDatabase* _tmp63_;
-		_tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
-		queue = _tmp0_;
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp1_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "DELETE FROM Object WHERE upnp_id LIKE '" RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "%'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp3_, "DROP TRIGGER trgr_update_closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp4_, "DROP TRIGGER trgr_delete_closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp5_, "DROP INDEX idx_parent", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp6_, "DROP INDEX idx_meta_data_fk", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp7_, "DROP INDEX IF EXISTS idx_closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp8_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp8_, "DROP TABLE Closure", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp9_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp9_, "DROP TRIGGER trgr_delete_metadata", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp10_ = self->priv->database;
-		_tmp11_ = _ (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME);
-		_tmp12_ = g_strconcat ("INSERT OR REPLACE INTO Object (parent, upnp_id, " "type_fk, title, timestamp) VALUES " "('0', '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "', 0, '", _tmp11_, NULL);
-		_tmp13_ = _tmp12_;
-		_tmp14_ = g_strconcat (_tmp13_, "', 0)", NULL);
-		_tmp15_ = _tmp14_;
-		rygel_media_export_database_exec (_tmp10_, _tmp15_, NULL, 0, &_inner_error_);
-		g_free (_tmp15_);
-		g_free (_tmp13_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp16_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp16_, "UPDATE Object SET parent = '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "' WHERE parent = '0' AND upnp_id " "NOT LIKE 'virtual-%' AND upnp_id " "<> '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp17_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp17_, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp18_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp18_, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp19_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp19_, "DELETE FROM Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp20_ = self->priv->database;
-		_tmp21_ = self->priv->sql;
-		_tmp22_ = rygel_media_export_sql_factory_make (_tmp21_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
-		rygel_media_export_database_exec (_tmp20_, _tmp22_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp23_ = self->priv->database;
-		_tmp24_ = self->priv->sql;
-		_tmp25_ = rygel_media_export_sql_factory_make (_tmp24_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
-		rygel_media_export_database_exec (_tmp23_, _tmp25_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp26_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp26_, "INSERT INTO Closure (ancestor, descendant, " "depth) VALUES ('0','0',0)", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp27_ = queue;
-		gee_queue_offer ((GeeQueue*) _tmp27_, "0");
-		while (TRUE) {
-			GeeLinkedList* _tmp28_;
-			gboolean _tmp29_;
-			gboolean _tmp30_;
-			GeeLinkedList* _tmp31_;
-			gpointer _tmp32_ = NULL;
-			GValue _tmp33_ = {0};
-			GValue* _tmp34_ = NULL;
-			GValue* args;
-			gint args_length1;
-			RygelMediaExportDatabase* _tmp35_;
-			GValue* _tmp36_;
-			gint _tmp36__length1;
-			RygelMediaExportDatabaseCursor* _tmp37_ = NULL;
-			RygelMediaExportDatabaseCursor* cursor;
-			RygelMediaExportDatabase* _tmp47_;
-			GValue* _tmp48_;
-			gint _tmp48__length1;
-			_tmp28_ = queue;
-			_tmp29_ = gee_collection_get_is_empty ((GeeCollection*) _tmp28_);
-			_tmp30_ = _tmp29_;
-			if (!(!_tmp30_)) {
-				break;
-			}
-			_tmp31_ = queue;
-			_tmp32_ = gee_queue_poll ((GeeQueue*) _tmp31_);
-			g_value_init (&_tmp33_, G_TYPE_STRING);
-			g_value_take_string (&_tmp33_, (gchar*) _tmp32_);
-			_tmp34_ = g_new0 (GValue, 1);
-			_tmp34_[0] = _tmp33_;
-			args = _tmp34_;
-			args_length1 = 1;
-			_tmp35_ = self->priv->database;
-			_tmp36_ = args;
-			_tmp36__length1 = args_length1;
-			_tmp37_ = rygel_media_export_database_exec_cursor (_tmp35_, "SELECT upnp_id FROM _Object WHERE " "parent = ?", _tmp36_, _tmp36__length1, &_inner_error_);
-			cursor = _tmp37_;
-			if (_inner_error_ != NULL) {
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-					goto __catch20_rygel_media_export_database_error;
-				}
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-				g_clear_error (&_inner_error_);
-				return;
-			}
-			{
-				while (TRUE) {
-					gboolean _tmp41_ = FALSE;
-					sqlite3_stmt* _tmp43_ = NULL;
-					sqlite3_stmt* statement;
-					GeeLinkedList* _tmp44_;
-					sqlite3_stmt* _tmp45_;
-					const gchar* _tmp46_ = NULL;
-					_tmp41_ = rygel_media_export_database_cursor_has_next (cursor);
-					if (!_tmp41_) {
-						break;
-					}
-					_tmp43_ = rygel_media_export_database_cursor_next (cursor, &_inner_error_);
-					statement = _tmp43_;
-					if (_inner_error_ != NULL) {
-						g_object_unref (cursor);
-						args = (_vala_GValue_array_free (args, args_length1), NULL);
-						g_object_unref (queue);
-						if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-							goto __catch20_rygel_media_export_database_error;
-						}
-						g_object_unref (cursor);
-						args = (_vala_GValue_array_free (args, args_length1), NULL);
-						g_object_unref (queue);
-						g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-						g_clear_error (&_inner_error_);
-						return;
-					}
-					_tmp44_ = queue;
-					_tmp45_ = statement;
-					_tmp46_ = (const gchar *) sqlite3_column_text (_tmp45_, 0);
-					gee_queue_offer ((GeeQueue*) _tmp44_, _tmp46_);
-				}
-			}
-			_tmp47_ = self->priv->database;
-			_tmp48_ = args;
-			_tmp48__length1 = args_length1;
-			rygel_media_export_database_exec (_tmp47_, "INSERT INTO Object SELECT * FROM _Object " "WHERE parent = ?", _tmp48_, _tmp48__length1, &_inner_error_);
-			if (_inner_error_ != NULL) {
-				g_object_unref (cursor);
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-					goto __catch20_rygel_media_export_database_error;
-				}
-				g_object_unref (cursor);
-				args = (_vala_GValue_array_free (args, args_length1), NULL);
-				g_object_unref (queue);
-				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-				g_clear_error (&_inner_error_);
-				return;
-			}
-			g_object_unref (cursor);
-			args = (_vala_GValue_array_free (args, args_length1), NULL);
-		}
-		_tmp49_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp49_, "DROP TABLE Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp50_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp50_, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp51_ = self->priv->database;
-		_tmp52_ = self->priv->sql;
-		_tmp53_ = rygel_media_export_sql_factory_make (_tmp52_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
-		rygel_media_export_database_exec (_tmp51_, _tmp53_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp54_ = self->priv->database;
-		_tmp55_ = self->priv->sql;
-		_tmp56_ = rygel_media_export_sql_factory_make (_tmp55_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
-		rygel_media_export_database_exec (_tmp54_, _tmp56_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp57_ = self->priv->database;
-		_tmp58_ = self->priv->sql;
-		_tmp59_ = rygel_media_export_sql_factory_make (_tmp58_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
-		rygel_media_export_database_exec (_tmp57_, _tmp59_, NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp60_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp60_, "UPDATE schema_info SET version = '10'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp61_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp61_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp62_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp62_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			g_object_unref (queue);
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch20_rygel_media_export_database_error;
-			}
-			g_object_unref (queue);
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp63_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp63_);
-		g_object_unref (queue);
-	}
-	goto __finally20;
-	__catch20_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp64_;
-		GError* _tmp65_;
-		const gchar* _tmp66_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp64_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp64_);
-		_tmp65_ = _error_;
-		_tmp66_ = _tmp65_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:343: Database upgrade fai" \
-"led: %s", _tmp66_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally20:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  g_debug ("Older schema detected. Upgrading...");
+  priv = self->priv;
+  current_version = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
+  while (old_version < current_version) {
+    if (!priv->database) {
+      break;
+    }
+
+    switch (old_version) {
+    case 3:
+      {
+	rygel_media_export_media_cache_upgrader_update_v3_v4 (self);
+	break;
+      }
+    case 4:
+      {
+	rygel_media_export_media_cache_upgrader_update_v4_v5 (self);
+	break;
+      }
+    case 5:
+      {
+	rygel_media_export_media_cache_upgrader_update_v5_v6 (self);
+	break;
+      }
+    case 6:
+      {
+	rygel_media_export_media_cache_upgrader_update_v6_v7 (self);
+	break;
+      }
+    case 7:
+      {
+	rygel_media_export_media_cache_upgrader_update_v7_v8 (self);
+	break;
+      }
+    case 8:
+      {
+	rygel_media_export_media_cache_upgrader_update_v8_v9 (self);
+	break;
+      }
+    case 9:
+      {
+	rygel_media_export_media_cache_upgrader_update_v9_v10 (self);
+	break;
+      }
+    case 10:
+      {
+	rygel_media_export_media_cache_upgrader_update_v10_v11 (self);
+	break;
+      }
+    default:
+      {
+	g_warning ("Cannot upgrade");
+	priv->database = NULL;
+	break;
+      }
+    }
+    ++old_version;
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_get_property (GObject    *object,
+						      guint       property_id,
+						      GValue     *value,
+						      GParamSpec *pspec) {
+  RygelMediaExportMediaCacheUpgrader *self = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER (object);
+  RygelMediaExportMediaCacheUpgraderPrivate *priv = self->priv;
+
+  switch (property_id) {
+  case RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DATABASE:
+    g_value_set_object (value, priv->database);
+    break;
+
+  case RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_SQL_FACTORY:
+    g_value_set_object (value, priv->sql);
+    break;
 
-static void rygel_media_export_media_cache_upgrader_update_v10_v11 (RygelMediaExportMediaCacheUpgrader* self) {
-	GError * _inner_error_ = NULL;
-	g_return_if_fail (self != NULL);
-	{
-		RygelMediaExportDatabase* _tmp0_;
-		RygelMediaExportDatabase* _tmp1_;
-		RygelMediaExportDatabase* _tmp2_;
-		RygelMediaExportDatabase* _tmp3_;
-		RygelMediaExportDatabase* _tmp4_;
-		RygelMediaExportDatabase* _tmp5_;
-		RygelMediaExportDatabase* _tmp6_;
-		_tmp0_ = self->priv->database;
-		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp1_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp1_, "ALTER TABLE Meta_Data " "   ADD COLUMN disc INTEGER", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp2_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp2_, "UPDATE Object SET timestamp = 0 WHERE " "  upnp_id IN (" "SELECT object_fk FROM Meta_Data WHERE " "  class LIKE 'object.item.audioItem.%')", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp3_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp3_, "UPDATE schema_info SET version = '11'", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp4_ = self->priv->database;
-		rygel_media_export_database_commit (_tmp4_, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp5_ = self->priv->database;
-		rygel_media_export_database_exec (_tmp5_, "VACUUM", NULL, 0, &_inner_error_);
-		if (_inner_error_ != NULL) {
-			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
-				goto __catch21_rygel_media_export_database_error;
-			}
-			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-			g_clear_error (&_inner_error_);
-			return;
-		}
-		_tmp6_ = self->priv->database;
-		rygel_media_export_database_analyze (_tmp6_);
-	}
-	goto __finally21;
-	__catch21_rygel_media_export_database_error:
-	{
-		GError* _error_ = NULL;
-		RygelMediaExportDatabase* _tmp7_;
-		GError* _tmp8_;
-		const gchar* _tmp9_;
-		_error_ = _inner_error_;
-		_inner_error_ = NULL;
-		_tmp7_ = self->priv->database;
-		rygel_media_export_database_rollback (_tmp7_);
-		_tmp8_ = _error_;
-		_tmp9_ = _tmp8_->message;
-		g_warning ("rygel-media-export-media-cache-upgrader.vala:364: Database upgrade fai" \
-"led: %s", _tmp9_);
-		self->priv->database = NULL;
-		g_error_free (_error_);
-	}
-	__finally21:
-	if (_inner_error_ != NULL) {
-		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
-		g_clear_error (&_inner_error_);
-		return;
-	}
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
-static void rygel_media_export_media_cache_upgrader_class_init (RygelMediaExportMediaCacheUpgraderClass * klass) {
-	rygel_media_export_media_cache_upgrader_parent_class = g_type_class_peek_parent (klass);
+static void
+rygel_media_export_media_cache_upgrader_set_property (GObject      *object,
+						      guint         property_id,
+						      const GValue *value,
+						      GParamSpec   *pspec) {
+  RygelMediaExportMediaCacheUpgrader *self = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER (object);
+  RygelMediaExportMediaCacheUpgraderPrivate *priv = self->priv;
+
+  switch (property_id) {
+  case RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DATABASE:
+    /* construct only property, unowned */
+    priv->database = g_value_get_object (value);
+    break;
+
+  case RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_SQL_FACTORY:
+    /* construct only property, unowned */
+    priv->sql = g_value_get_object (value);
+    break;
 
-	g_type_class_add_private (klass, sizeof (RygelMediaExportMediaCacheUpgraderPrivate));
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
+static void
+rygel_media_export_media_cache_upgrader_class_init (RygelMediaExportMediaCacheUpgraderClass *upgrader_class) {
+  GObjectClass *object_class = G_OBJECT_CLASS (upgrader_class);
+
+  object_class->get_property = rygel_media_export_media_cache_upgrader_get_property;
+  object_class->set_property = rygel_media_export_media_cache_upgrader_set_property;
+
+  g_object_class_install_property (object_class,
+				   RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DATABASE,
+				   g_param_spec_object ("database",
+							"database",
+							"database",
+							RYGEL_MEDIA_EXPORT_TYPE_DATABASE,
+							G_PARAM_READABLE |
+							G_PARAM_WRITABLE |
+							G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+				   RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_SQL_FACTORY,
+				   g_param_spec_object ("sql-factory",
+							"sql-factory",
+							"sql-factory",
+							RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY,
+							G_PARAM_READABLE |
+							G_PARAM_WRITABLE |
+							G_PARAM_CONSTRUCT_ONLY));
+
+  g_type_class_add_private (upgrader_class, sizeof (RygelMediaExportMediaCacheUpgraderPrivate));
+}
 
-static void rygel_media_export_media_cache_upgrader_init (RygelMediaExportMediaCacheUpgrader * self) {
-	self->priv = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_PRIVATE (self);
+static void
+rygel_media_export_media_cache_upgrader_init (RygelMediaExportMediaCacheUpgrader *self) {
+  self->priv = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_PRIVATE (self);
 }



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