Browse Source

LIMIT is no column but a SQL feature, allow limit on initial sync

Signed-off-by: Georg Ehrke <developer@georgehrke.com>
tags/v17.0.0beta1
Georg Ehrke 5 years ago
parent
commit
9f6dd51912
No account linked to committer's email address

+ 1
- 0
apps/dav/composer/composer/autoload_classmap.php View File

@@ -147,6 +147,7 @@ return array(
'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php',
'OCA\\DAV\\Files\\FilesHome' => $baseDir . '/../lib/Files/FilesHome.php',

+ 1
- 0
apps/dav/composer/composer/autoload_static.php View File

@@ -162,6 +162,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__ . '/..' . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php',
'OCA\\DAV\\Files\\FilesHome' => __DIR__ . '/..' . '/../lib/Files/FilesHome.php',

+ 12
- 0
apps/dav/lib/CalDAV/CachedSubscription.php View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
*/
namespace OCA\DAV\CalDAV;

use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\Exception\NotFound;
@@ -195,4 +196,15 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
public function calendarQuery(array $filters):array {
return $this->caldavBackend->calendarQuery($this->calendarInfo['id'], $filters, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION);
}

/**
* @inheritDoc
*/
public function getChanges($syncToken, $syncLevel, $limit = null) {
if (!$syncToken && $limit) {
throw new UnsupportedLimitOnInitialSyncException();
}

return parent::getChanges($syncToken, $syncLevel, $limit);
}
}

+ 11
- 0
apps/dav/lib/CalDAV/Calendar.php View File

@@ -27,6 +27,7 @@
namespace OCA\DAV\CalDAV;

use OCA\DAV\DAV\Sharing\IShareable;
use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
use OCP\IConfig;
use OCP\IL10N;
use Sabre\CalDAV\Backend\BackendInterface;
@@ -339,4 +340,14 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
return isset($this->calendarInfo['{http://calendarserver.org/ns/}source']);
}

/**
* @inheritDoc
*/
public function getChanges($syncToken, $syncLevel, $limit = null) {
if (!$syncToken && $limit) {
throw new UnsupportedLimitOnInitialSyncException();
}

return parent::getChanges($syncToken, $syncLevel, $limit);
}
}

+ 9
- 0
apps/dav/lib/CardDAV/AddressBook.php View File

@@ -23,6 +23,7 @@
namespace OCA\DAV\CardDAV;

use OCA\DAV\DAV\Sharing\IShareable;
use OCA\DAV\Exception\UnsupportedLimitOnInitialSyncException;
use OCP\IL10N;
use Sabre\CardDAV\Backend\BackendInterface;
use Sabre\CardDAV\Card;
@@ -219,4 +220,12 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
}
return true;
}

public function getChanges($syncToken, $syncLevel, $limit = null) {
if (!$syncToken && $limit) {
throw new UnsupportedLimitOnInitialSyncException();
}

return parent::getChanges($syncToken, $syncLevel, $limit);
}
}

+ 1
- 1
apps/dav/lib/CardDAV/CardDavBackend.php View File

@@ -814,7 +814,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {

$query = "SELECT `uri`, `operation` FROM `*PREFIX*addressbookchanges` WHERE `synctoken` >= ? AND `synctoken` < ? AND `addressbookid` = ? ORDER BY `synctoken`";
if ($limit>0) {
$query .= " `LIMIT` " . (int)$limit;
$query .= " LIMIT " . (int)$limit;
}

// Fetching all changes

+ 41
- 0
apps/dav/lib/Exception/UnsupportedLimitOnInitialSyncException.php View File

@@ -0,0 +1,41 @@
<?php

/**
* @copyright Copyright (c) 2019 Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
*
* @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\Exception;

use Sabre\DAV\Exception\InsufficientStorage;
use Sabre\DAV\Server;

/**
* Class UnsupportedLimitOnInitialSyncException
*
* @package OCA\DAV\Exception
*/
class UnsupportedLimitOnInitialSyncException extends InsufficientStorage {

/**
* @inheritDoc
*/
public function serialize(Server $server, \DOMElement $errorNode) {
$errorNode->appendChild($errorNode->ownerDocument->createElementNS('DAV:', 'd:number-of-matches-within-limits'));
}
}

Loading…
Cancel
Save