Catch exceptions during sync

This commit is contained in:
Thomas Müller 2015-12-21 17:32:39 +01:00
parent ca8c9f6ad5
commit 94856cb892
2 changed files with 8 additions and 7 deletions

View file

@ -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;

View file

@ -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();