]> source.dussan.org Git - nextcloud-server.git/commitdiff
Tweak failure message and throw exceptions from updateDbFromStructure()
authorMichael Gapczynski <mtgap@owncloud.com>
Sat, 5 Jan 2013 17:13:36 +0000 (12:13 -0500)
committerMichael Gapczynski <mtgap@owncloud.com>
Sat, 5 Jan 2013 17:13:36 +0000 (12:13 -0500)
core/ajax/update.php
lib/app.php
lib/db.php

index 1c77a4ab67e04d5c19be59fde43ba3a768de1f7d..20ab045c89243b09f433dac2900caba7acb57b17 100644 (file)
@@ -10,11 +10,12 @@ if (OC::checkUpgrade(false)) {
        OC_Hook::connect('update', 'error', $watcher, 'error');
        OC_Hook::connect('update', 'error', $watcher, 'failure');
        $watcher->success('Turned on maintenance mode');
-       $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
-       if (!$result) {
-               $watcher->failure('Error updating database');
+       try {
+               $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml');
+               $watcher->success('Updated database');
+       } catch (Exception $exception) {
+               $watcher->failure($exception->getMessage());
        }
-       $watcher->success('Updated database');
        $minimizerCSS = new OC_Minimizer_CSS();
        $minimizerCSS->clearCache();
        $minimizerJS = new OC_Minimizer_JS();
index 48bbe53c744a6d1b0d5d6d2413a0b59fe065e1e5..9d4ead71b90075792a5fb04e7989d2f2c573dca6 100755 (executable)
@@ -642,7 +642,7 @@ class OC_App{
                                }
                                catch (Exception $e) {
                                        echo 'Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"';
-                                       OC_Hook::emit('update', 'failure', 'Error updating '.$info['name'].' app: '.$e->getMessage());
+                                       OC_Hook::emit('update', 'failure', 'Failed to update '.$info['name'].' app: '.$e->getMessage());
                                        die;
                                }
                                OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
index 7e60b41d2305434a0b95ed2bd0191f7bd4ba2e1e..74e7ca5b0e0957db219ba60f71a49e528cd1d265 100644 (file)
@@ -495,8 +495,9 @@ class OC_DB {
                if (PEAR::isError($previousSchema)) {
                        $error = $previousSchema->getMessage();
                        $detail = $previousSchema->getDebugInfo();
-                       OC_Log::write('core', 'Failed to get existing database structure for upgrading ('.$error.', '.$detail.')', OC_Log::FATAL);
-                       return false;
+                       $message = 'Failed to get existing database structure for updating ('.$error.', '.$detail.')';
+                       OC_Log::write('core', $message, OC_Log::FATAL);
+                       throw new Exception($message);
                }
 
                // Make changes and save them to an in-memory file
@@ -523,8 +524,9 @@ class OC_DB {
                if (PEAR::isError($op)) {
                        $error = $op->getMessage();
                        $detail = $op->getDebugInfo();
-                       OC_Log::write('core', 'Failed to update database structure ('.$error.', '.$detail.')', OC_Log::FATAL);
-                       return false;
+                       $message = 'Failed to update database structure ('.$error.', '.$detail.')';
+                       OC_Log::write('core', $message, OC_Log::FATAL);
+                       throw new Exception($message);
                }
                return true;
        }