Suppress warnings from DAV migration if there's nothing to do (#25279)

This commit is contained in:
Thomas Müller 2016-07-01 11:30:14 +02:00 committed by GitHub
parent abdc587b5c
commit 4a4103b923
4 changed files with 34 additions and 2 deletions

View File

@ -32,6 +32,7 @@ use OCA\Dav\Migration\AddressBookAdapter;
use OCA\Dav\Migration\CalendarAdapter; use OCA\Dav\Migration\CalendarAdapter;
use OCA\Dav\Migration\MigrateAddressbooks; use OCA\Dav\Migration\MigrateAddressbooks;
use OCA\Dav\Migration\MigrateCalendars; use OCA\Dav\Migration\MigrateCalendars;
use OCA\Dav\Migration\NothingToDoException;
use \OCP\AppFramework\App; use \OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer; use OCP\AppFramework\IAppContainer;
use OCP\Contacts\IManager; use OCP\Contacts\IManager;
@ -190,6 +191,8 @@ class Application extends App {
/** @var IUser $user */ /** @var IUser $user */
$migration->migrateForUser($user->getUID()); $migration->migrateForUser($user->getUID());
}); });
} catch (NothingToDoException $ex) {
// nothing to do, yay!
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->getContainer()->getServer()->getLogger()->logException($ex); $this->getContainer()->getServer()->getLogger()->logException($ex);
} }
@ -206,6 +209,8 @@ class Application extends App {
/** @var IUser $user */ /** @var IUser $user */
$migration->migrateForUser($user->getUID()); $migration->migrateForUser($user->getUID());
}); });
} catch (NothingToDoException $ex) {
// nothing to do, yay!
} catch (\Exception $ex) { } catch (\Exception $ex) {
$this->getContainer()->getServer()->getLogger()->logException($ex); $this->getContainer()->getServer()->getLogger()->logException($ex);
} }

View File

@ -69,7 +69,7 @@ class AddressBookAdapter {
public function setup() { public function setup() {
if (!$this->dbConnection->tableExists($this->sourceBookTable)) { if (!$this->dbConnection->tableExists($this->sourceBookTable)) {
throw new \DomainException('Contacts tables are missing. Nothing to do.'); throw new NothingToDoException('Contacts tables are missing');
} }
} }

View File

@ -65,7 +65,7 @@ class CalendarAdapter {
public function setup() { public function setup() {
if (!$this->dbConnection->tableExists($this->sourceCalendarTable)) { if (!$this->dbConnection->tableExists($this->sourceCalendarTable)) {
throw new \DomainException('Calendar tables are missing. Nothing to do.'); throw new NothingToDoException('Calendar tables are missing');
} }
} }

View File

@ -0,0 +1,27 @@
<?php
/**
* @author Robin McCorkell <robin@mccorkell.me.uk>
*
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Dav\Migration;
/**
* Exception if no migration needs to be done
*/
class NothingToDoException extends \DomainException {}