From 94856cb892bba5b123c3f7e9ebeb042c960f72dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 21 Dec 2015 17:32:39 +0100 Subject: [PATCH] Catch exceptions during sync --- apps/dav/lib/carddav/syncservice.php | 5 +---- apps/federation/command/syncfederationaddressbooks.php | 10 +++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/carddav/syncservice.php b/apps/dav/lib/carddav/syncservice.php index 494db61d98..b8dfcfdbc5 100644 --- a/apps/dav/lib/carddav/syncservice.php +++ b/apps/dav/lib/carddav/syncservice.php @@ -24,6 +24,7 @@ namespace OCA\DAV\CardDAV; use Sabre\DAV\Client; use Sabre\DAV\Xml\Response\MultiStatus; use Sabre\DAV\Xml\Service; +use Sabre\HTTP\ClientException; class SyncService { @@ -112,10 +113,6 @@ class SyncService { 'Content-Type' => 'application/xml' ]); -// if ((int)$response->getStatus() >= 400) { -// throw new Exception('HTTP error: ' . $response->getStatus()); -// } - $result = $this->parseMultiStatus($response['body']); return $result; diff --git a/apps/federation/command/syncfederationaddressbooks.php b/apps/federation/command/syncfederationaddressbooks.php index d7761d1481..9fb1e51f64 100644 --- a/apps/federation/command/syncfederationaddressbooks.php +++ b/apps/federation/command/syncfederationaddressbooks.php @@ -63,9 +63,13 @@ class SyncFederationAddressBooks extends Command { $targetBookProperties = [ '{DAV:}displayname' => $url ]; - $newToken = $this->syncService->syncRemoteAddressBook($url, 'system', $sharedSecret, $syncToken, $targetPrincipal, $targetBookId, $targetBookProperties); - if ($newToken !== $syncToken) { - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); + try { + $newToken = $this->syncService->syncRemoteAddressBook($url, 'system', $sharedSecret, $syncToken, $targetPrincipal, $targetBookId, $targetBookProperties); + if ($newToken !== $syncToken) { + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); + } + } catch (\Exception $ex) { + $output->writeln("Error while syncing $url : " . $ex->getMessage()); } } $progress->finish();