diff options
author | C. Montero Luque <cmonteroluque@users.noreply.github.com> | 2016-03-01 13:35:14 -0500 |
---|---|---|
committer | C. Montero Luque <cmonteroluque@users.noreply.github.com> | 2016-03-01 13:35:14 -0500 |
commit | c51a01b43f514fc50c47de1ed78d2bdfb8572621 (patch) | |
tree | c191f06bd08833e7b4d70a80ca8d9981c97b3d0d /apps/dav/lib | |
parent | 2d68c1b9450d77d21b08fc66436d286996583589 (diff) | |
parent | 745fdc48007d5d2f29c62266627731bd0ea0aa3d (diff) | |
download | nextcloud-server-c51a01b43f514fc50c47de1ed78d2bdfb8572621.tar.gz nextcloud-server-c51a01b43f514fc50c47de1ed78d2bdfb8572621.zip |
Merge branch 'master' into exclude-custom-data-dir
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/carddav/syncservice.php | 21 | ||||
-rw-r--r-- | apps/dav/lib/connector/sabre/file.php | 15 | ||||
-rw-r--r-- | apps/dav/lib/connector/sabre/filesplugin.php | 7 |
3 files changed, 39 insertions, 4 deletions
diff --git a/apps/dav/lib/carddav/syncservice.php b/apps/dav/lib/carddav/syncservice.php index 4b5907620e6..2e7397fc70b 100644 --- a/apps/dav/lib/carddav/syncservice.php +++ b/apps/dav/lib/carddav/syncservice.php @@ -21,11 +21,14 @@ namespace OCA\DAV\CardDAV; +use OCP\AppFramework\Http; +use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use Sabre\DAV\Client; use Sabre\DAV\Xml\Response\MultiStatus; use Sabre\DAV\Xml\Service; +use Sabre\HTTP\ClientHttpException; use Sabre\VObject\Reader; class SyncService { @@ -36,12 +39,16 @@ class SyncService { /** @var IUserManager */ private $userManager; + /** @var ILogger */ + private $logger; + /** @var array */ private $localSystemAddressBook; - public function __construct(CardDavBackend $backend, IUserManager $userManager) { + public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger) { $this->backend = $backend; $this->userManager = $userManager; + $this->logger = $logger; } /** @@ -53,6 +60,7 @@ class SyncService { * @param string $targetPrincipal * @param array $targetProperties * @return string + * @throws \Exception */ public function syncRemoteAddressBook($url, $userName, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) { // 1. create addressbook @@ -60,7 +68,16 @@ class SyncService { $addressBookId = $book['id']; // 2. query changes - $response = $this->requestSyncReport($url, $userName, $sharedSecret, $syncToken); + try { + $response = $this->requestSyncReport($url, $userName, $sharedSecret, $syncToken); + } catch (ClientHttpException $ex) { + if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { + // remote server revoked access to the address book, remove it + $this->backend->deleteAddressBook($addressBookId); + $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']); + throw $ex; + } + } // 3. apply changes // TODO: use multi-get for download diff --git a/apps/dav/lib/connector/sabre/file.php b/apps/dav/lib/connector/sabre/file.php index 38a1ee5f4e2..9c8344bc5db 100644 --- a/apps/dav/lib/connector/sabre/file.php +++ b/apps/dav/lib/connector/sabre/file.php @@ -215,11 +215,16 @@ class File extends Node implements IFile { } } + $this->refreshInfo(); + if (isset($request->server['HTTP_OC_CHECKSUM'])) { $checksum = trim($request->server['HTTP_OC_CHECKSUM']); $this->fileView->putFileInfo($this->path, ['checksum' => $checksum]); + $this->refreshInfo(); + } else if ($this->getChecksum() !== null && $this->getChecksum() !== '') { + $this->fileView->putFileInfo($this->path, ['checksum' => '']); + $this->refreshInfo(); } - $this->refreshInfo(); } catch (StorageNotAvailableException $e) { throw new ServiceUnavailable("Failed to check file size: " . $e->getMessage()); @@ -457,8 +462,16 @@ class File extends Node implements IFile { $this->emitPostHooks($exists, $targetPath); + // FIXME: should call refreshInfo but can't because $this->path is not the of the final file $info = $this->fileView->getFileInfo($targetPath); + if (isset($request->server['HTTP_OC_CHECKSUM'])) { + $checksum = trim($request->server['HTTP_OC_CHECKSUM']); + $this->fileView->putFileInfo($targetPath, ['checksum' => $checksum]); + } else if ($info->getChecksum() !== null && $info->getChecksum() !== '') { + $this->fileView->putFileInfo($this->path, ['checksum' => '']); + } + $this->fileView->unlockFile($targetPath, ILockingProvider::LOCK_SHARED); return $info->getEtag(); diff --git a/apps/dav/lib/connector/sabre/filesplugin.php b/apps/dav/lib/connector/sabre/filesplugin.php index eb9116d219b..4b05922adfd 100644 --- a/apps/dav/lib/connector/sabre/filesplugin.php +++ b/apps/dav/lib/connector/sabre/filesplugin.php @@ -27,6 +27,7 @@ namespace OCA\DAV\Connector\Sabre; +use Sabre\DAV\Exception\NotFound; use Sabre\DAV\IFile; use \Sabre\DAV\PropFind; use \Sabre\DAV\PropPatch; @@ -197,7 +198,7 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { //Add OC-Checksum header /** @var $node File */ $checksum = $node->getChecksum(); - if ($checksum !== null) { + if ($checksum !== null && $checksum !== '') { $response->addHeader('OC-Checksum', $checksum); } } @@ -252,6 +253,10 @@ class FilesPlugin extends \Sabre\DAV\ServerPlugin { $propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) { $checksum = $node->getChecksum(); + if ($checksum === NULL || $checksum === '') { + return null; + } + return new ChecksumList($checksum); }); |