[rygel] MediaExport: Don't activate on upgrade fail
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] MediaExport: Don't activate on upgrade fail
- Date: Sun, 23 May 2021 16:50:53 +0000 (UTC)
commit d4cf4b8bf4ab2f46a842c5f107fea80469b52cd5
Author: Jens Georg <mail jensge org>
Date: Wed Feb 24 00:22:11 2021 +0100
MediaExport: Don't activate on upgrade fail
Properly deactivate plugin on start
Fixes #166
.../rygel-media-export-media-cache-upgrader.vala | 17 +++++------------
.../media-export/rygel-media-export-media-cache.vala | 3 ++-
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 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]