[Pkg-owncloud-commits] [owncloud] 59/118: Properly forward repair errors and warnings

David Prévot taffit at moszumanska.debian.org
Fri Mar 27 22:13:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 04809b603795d19c02f7a95c93146186593729b8
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri Feb 27 12:44:04 2015 +0100

    Properly forward repair errors and warnings
    
    This makes repair errors and warnings visible for the user when
    upgrading on the command line or in the web UI.
---
 core/ajax/update.php                        |  6 ++++++
 core/command/maintenance/repair.php         |  3 +++
 core/command/upgrade.php                    |  6 ++++++
 lib/private/repair/repairlegacystorages.php | 15 ++++++++++++++-
 lib/private/updater.php                     | 16 ++++++++++++++++
 5 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/core/ajax/update.php b/core/ajax/update.php
index a9ab731..6d2dccf 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -37,6 +37,12 @@ if (OC::checkUpgrade(false)) {
 	$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
 		$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
 	});
+	$updater->listen('\OC\Updater', 'repairWarning', function ($description) use ($eventSource, $l) {
+		$eventSource->send('notice', (string)$l->t('Repair warning: ') . $description);
+	});
+	$updater->listen('\OC\Updater', 'repairError', function ($description) use ($eventSource, $l) {
+		$eventSource->send('notice', (string)$l->t('Repair error: ') . $description);
+	});
 	$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
 		$incompatibleApps[]= $app;
 	});
diff --git a/core/command/maintenance/repair.php b/core/command/maintenance/repair.php
index bf94b26..bf2cac3 100644
--- a/core/command/maintenance/repair.php
+++ b/core/command/maintenance/repair.php
@@ -46,6 +46,9 @@ class Repair extends Command {
 		$this->repair->listen('\OC\Repair', 'info', function ($description) use ($output) {
 			$output->writeln('     - ' . $description);
 		});
+		$this->repair->listen('\OC\Repair', 'warning', function ($description) use ($output) {
+			$output->writeln('     - WARNING: ' . $description);
+		});
 		$this->repair->listen('\OC\Repair', 'error', function ($description) use ($output) {
 			$output->writeln('     - ERROR: ' . $description);
 		});
diff --git a/core/command/upgrade.php b/core/command/upgrade.php
index e540279..8c3fbac 100644
--- a/core/command/upgrade.php
+++ b/core/command/upgrade.php
@@ -113,6 +113,12 @@ class Upgrade extends Command {
 			$updater->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use($output) {
 				$output->writeln('<info>Disabled 3rd-party app: ' . $app . '</info>');
 			});
+			$updater->listen('\OC\Updater', 'repairWarning', function ($app) use($output) {
+				$output->writeln('<error>Repair warning: ' . $app . '</error>');
+			});
+			$updater->listen('\OC\Updater', 'repairError', function ($app) use($output) {
+				$output->writeln('<error>Repair error: ' . $app . '</error>');
+			});
 			$updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) {
 				$output->writeln('<info>Checked database schema update for apps</info>');
 			});
diff --git a/lib/private/repair/repairlegacystorages.php b/lib/private/repair/repairlegacystorages.php
index f09ca2b..027cb68 100644
--- a/lib/private/repair/repairlegacystorages.php
+++ b/lib/private/repair/repairlegacystorages.php
@@ -143,6 +143,7 @@ class RepairLegacyStorages extends BasicEmitter {
 		$dataDirId = 'local::' . $dataDir;
 
 		$count = 0;
+		$hasWarnings = false;
 
 		$this->connection->beginTransaction();
 
@@ -167,6 +168,7 @@ class RepairLegacyStorages extends BasicEmitter {
 				}
 			}
 			catch (\OC\RepairException $e) {
+				$hasWarnings = true;
 				$this->emit(
 					'\OC\Repair',
 					'warning',
@@ -180,6 +182,7 @@ class RepairLegacyStorages extends BasicEmitter {
 			. ' WHERE `id` NOT LIKE \'%::%\'';
 		$result = $this->connection->executeQuery($sql);
 		$row = $result->fetch();
+
 		// find at least one to make sure it's worth
 		// querying the user list
 		if ((int)$row['c'] > 0) {
@@ -213,6 +216,7 @@ class RepairLegacyStorages extends BasicEmitter {
 							}
 						}
 						catch (\OC\RepairException $e) {
+							$hasWarnings = true;
 							$this->emit(
 								'\OC\Repair',
 								'warning',
@@ -229,6 +233,15 @@ class RepairLegacyStorages extends BasicEmitter {
 
 		$this->connection->commit();
 
-		$this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+		if ($hasWarnings) {
+			$this->emit(
+				'\OC\Repair',
+				'warning',
+				array('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair')
+			);
+		} else {
+			// if all were done, no need to redo the repair during next upgrade
+			$this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+		}
 	}
 }
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 485bf7e..08731c7 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -173,6 +173,20 @@ class Updater extends BasicEmitter {
 	}
 
 	/**
+	 * Forward messages emitted by the repair routine
+	 *
+	 * @param Repair $repair repair routine
+	 */
+	private function emitRepairMessages(Repair $repair) {
+		$repair->listen('\OC\Repair', 'warning', function ($description) {
+			$this->emit('\OC\Updater', 'repairWarning', array($description));
+		});
+		$repair->listen('\OC\Repair', 'error', function ($description) {
+			$this->emit('\OC\Updater', 'repairError', array($description));
+		});
+	}
+
+	/**
 	 * runs the update actions in maintenance mode, does not upgrade the source files
 	 * except the main .htaccess file
 	 *
@@ -204,6 +218,7 @@ class Updater extends BasicEmitter {
 
 		// pre-upgrade repairs
 		$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
+		$this->emitRepairMessages($repair);
 		$repair->run();
 
 		// simulate DB upgrade
@@ -223,6 +238,7 @@ class Updater extends BasicEmitter {
 
 			// post-upgrade repairs
 			$repair = new Repair(Repair::getRepairSteps());
+			$this->emitRepairMessages($repair);
 			$repair->run();
 
 			//Invalidate update feed

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list