[rygel] media-export: Refactor database upgrade



commit 9a984521626a1debe14c182f76c18f2ead694cc6
Author: Jens Georg <mail jensge org>
Date:   Fri May 7 21:12:33 2010 +0200

    media-export: Refactor database upgrade

 .../rygel-media-export-media-cache.vala            |   40 +++++++++-----------
 1 files changed, 18 insertions(+), 22 deletions(-)
---
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 b9dd629..f8fceb2 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -542,29 +542,25 @@ public class Rygel.MediaExport.MediaCache : Object {
             } else {
                 if (old_version < current_version) {
                     debug ("Older schema detected. Upgrading...");
-                    switch (old_version) {
-                        case 3:
-                            update_v3_v4 ();
-                            if (this.db != null) {
-                                update_v4_v5 ();
+                    while (old_version < current_version) {
+                        if (this.db != null) {
+                            switch (old_version) {
+                                case 3:
+                                    update_v3_v4 ();
+                                    break;
+                                case 4:
+                                    update_v4_v5 ();
+                                    break;
+                                case 5:
+                                    update_v5_v6 ();
+                                    break;
+                                default:
+                                    warning ("Cannot upgrade");
+                                    db = null;
+                                    break;
                             }
-                            if (this.db != null) {
-                                update_v5_v6 ();
-                            }
-                            break;
-                        case 4:
-                            update_v4_v5 ();
-                            if (this.db != null) {
-                                update_v5_v6 ();
-                            }
-                            break;
-                        case 5:
-                            update_v5_v6 ();
-                            break;
-                        default:
-                            warning ("Cannot upgrade");
-                            db = null;
-                            break;
+                            old_version++;
+                        }
                     }
                 } else {
                     warning ("The version \"%d\" of the detected database" +



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