]> source.dussan.org Git - nextcloud-server.git/commitdiff
Catch exceptions during sync
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 21 Dec 2015 16:32:39 +0000 (17:32 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 12 Jan 2016 13:24:47 +0000 (14:24 +0100)
apps/dav/lib/carddav/syncservice.php
apps/federation/command/syncfederationaddressbooks.php

index 494db61d9892d0a0fd221cf61c3d94b6936678a6..b8dfcfdbc5e03c708357b29bf6c8b616369bccd9 100644 (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;
index d7761d14814b1d6bdae1ff343323ea23d36b4446..9fb1e51f643cc1bf467de3ec16da41c7d6790ad6 100644 (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();