summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2021-02-24 00:22:11 +0100
committerJens Georg <mail@jensge.org>2021-05-23 18:31:13 +0200
commitd4cf4b8bf4ab2f46a842c5f107fea80469b52cd5 (patch)
tree2bb95b745a5b6bdeff8cb7f2935603298283970d
parent10848ca3e2b846292deb0b7a42a57f01d979c271 (diff)
downloadrygel-d4cf4b8bf4ab2f46a842c5f107fea80469b52cd5.tar.gz
MediaExport: Don't activate on upgrade fail
Properly deactivate plugin on start Fixes #166
-rw-r--r--src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala17
-rw-r--r--src/plugins/media-export/rygel-media-export-media-cache.vala3
2 files changed, 7 insertions, 13 deletions
diff --git a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
index b516558b..adf84397 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache-upgrader.vala
@@ -80,33 +80,27 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
}
}
- public void upgrade (int old_version) {
+ public void upgrade (int old_version) throws MediaCacheError {
debug ("Older schema detected. Upgrading...");
int current_version = int.parse (SQLFactory.SCHEMA_VERSION);
while (old_version < current_version) {
- if (this.database == null) {
- break;
- }
-
switch (old_version) {
case 16:
this.update_v17_v18 (false);
- // We jump 17 here since 17 -> 18 is just a table rename
+ // We skip 17 here since 17 -> 18 is just a table rename
old_version++;
break;
case 17:
this.update_v17_v18 (true);
break;
default:
- warning (_("Cannot upgrade from version %d"), old_version);
- database = null;
- break;
+ throw new MediaCacheError.UPGRADE_FAILED (_("Cannot upgrade from version %d"), old_version);
}
old_version++;
}
}
- private void update_v17_v18 (bool move_data) {
+ private void update_v17_v18 (bool move_data) throws MediaCacheError {
try {
this.database.begin ();
this.database.exec (this.sql.make (SQLString.CREATE_IGNORELIST_TABLE));
@@ -120,8 +114,7 @@ internal class Rygel.MediaExport.MediaCacheUpgrader {
this.database.analyze ();
} catch (Database.DatabaseError error) {
database.rollback ();
- warning (_("Database upgrade to v18 failed: %s"), error.message);
- database = null;
+ throw new MediaCacheError.UPGRADE_FAILED (_("Database upgrade to v18 failed: %s"), error.message);
}
}
}
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index a494b255..a905bc5a 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -33,7 +33,8 @@ public errordomain Rygel.MediaExport.MediaCacheError {
SQLITE_ERROR,
GENERAL_ERROR,
INVALID_TYPE,
- UNSUPPORTED_SEARCH
+ UNSUPPORTED_SEARCH,
+ UPGRADE_FAILED
}
internal enum Rygel.MediaExport.ObjectType {