Don't waste energy unless necessary

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-03-02 11:24:56 +01:00
parent 2ca0ada4c9
commit ba30fa0e10
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 21 additions and 16 deletions

View File

@ -278,6 +278,10 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
->execute();
while($row = $result->fetch()) {
if (isset($calendars[$row['id']])) {
continue;
}
list(, $name) = URLUtil::splitPath($row['principaluri']);
$uri = $row['uri'] . '_shared_by_' . $name;
$row['displayname'] = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
@ -301,9 +305,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendar[$xmlName] = $row[$dbName];
}
if (!isset($calendars[$calendar['id']])) {
$calendars[$calendar['id']] = $calendar;
}
$calendars[$calendar['id']] = $calendar;
}
$result->closeCursor();

View File

@ -173,22 +173,25 @@ class CardDavBackend implements BackendInterface, SyncSupport {
->execute();
while($row = $result->fetch()) {
if (isset($addressBooks[$row['id']])) {
continue;
}
list(, $name) = URLUtil::splitPath($row['principaluri']);
$uri = $row['uri'] . '_shared_by_' . $name;
$displayName = $row['displayname'] . ' (' . $this->getUserDisplayName($name) . ')';
if (!isset($addressBooks[$row['id']])) {
$addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $uri,
'principaluri' => $principalUriOriginal,
'{DAV:}displayname' => $displayName,
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
];
}
$addressBooks[$row['id']] = [
'id' => $row['id'],
'uri' => $uri,
'principaluri' => $principalUriOriginal,
'{DAV:}displayname' => $displayName,
'{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'],
'{http://calendarserver.org/ns/}getctag' => $row['synctoken'],
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ,
];
}
$result->closeCursor();