Repository navigation
perf(dav): sync federated calendars with calendar-multiget - #65944
SebastianKrupinski wants to merge 1 commit into
Conversation
728b718 to
ef428f9
Compare
DerDreschner
left a comment
There was a problem hiding this comment.
This branch is based on an older version of #65942 (0a4754c17b, current is 4524e68cc0), which is why the diff shows #65942's changes again. The difference is only three blank lines in SyncServiceTest.php, and the calendar commit rebases cleanly. My comments on the shared ASyncService/CardDAV code are on #65942 and apply to calendars too (parse failures, missing hrefs, batch size). The inline comments here are about the calendar part only.
Outside the diff:
CalDAV/SyncService.php:61keeps its per-object GET loop and// TODO: use multi-get for download. The class has no callers, so removing it (separately) is probably simpler than converting it.- The code-style checks fail: the double blank lines in
SyncServiceTest.phpgo away with the rebase;FederatedCalendarSyncServiceTest.php:298still needs single quotes (composer cs:fix). - Neither commit has an
Assisted-bytrailer, although the AI box in the description is ticked.
Assisted by ClaudeCode:claude-opus-5-5
| $credentials['token'], | ||
| $batch, | ||
| $reportName, | ||
| '{' . Plugin::NS_CALDAV . '}calendar-data', |
There was a problem hiding this comment.
Sabre's CalDAV plugin strips every \r from calendar-data in multiget responses ("Taking out \r to not screw up the xml output"), so objects synced this way are stored with LF line endings, while the GET fallback keeps CRLF. The local ETag and size then differ from the sharer's copy, and local clients get iCalendar without the CRLF that RFC 5545 requires. The test doesn't catch it because the mock encodes \r as , which Sabre never sends for calendar-data.
Converting back to CRLF (VObject read + serialize, or \n → \r\n) and making the mock strip \r like Sabre does would fix it.
|
|
||
| // federated calendar shares only need the CalDAV reports, e.g. calendar-multiget for syncing | ||
| if ($this->requestIsForSubtree(['remote-calendars'])) { | ||
| $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
There was a problem hiding this comment.
The comment says only the CalDAV reports are needed, but this registers the whole CalDAV plugin for remote-calendars, including validateICalendar for PUTs and MKCALENDAR. When validation repairs an object, Sabre stores it without returning an ETag, and FederatedCalendar::createFile()/updateFile() on the receiver throw on the empty ETag after the sharer already saved the object, so the user gets a 500 for an event that exists. PUTs that used to be accepted can also be rejected with 415 now.
Registering only what the sync needs, or explicitly accepting and testing the new PUT validation, would avoid that.
| * @param list<string> $hrefs | ||
| * @return \Generator<string, string> Calendar data keyed by href | ||
| * | ||
| * @throws ClientExceptionInterface If a remote request fails. |
There was a problem hiding this comment.
requestMultiGet() can also throw Sabre\Xml\LibXMLException (see the parse-failure comment on #65942). That's not a ClientExceptionInterface, so it gets past the catch blocks of FederatedCalendarPeriodicSyncJob and FederatedCalendarSyncJob: the periodic job stops for all remaining calendars, and FederatedCalendarSyncJob skips its setLastSync(1) fallback.
| $reportName = '{' . Plugin::NS_CALDAV . '}calendar-multiget'; | ||
| // Older remotes do not support calendar-multiget for federated calendars and | ||
| // would log the rejected report as an error, so ask before sending it | ||
| if (!$this->requestReportSupport($credentials['remoteUrl'], $credentials['username'], $credentials['token'], $reportName)) { |
There was a problem hiding this comment.
Nit: this PROPFIND runs on every sync of every calendar with changes. Caching the result per remote for the duration of a run would save most of them.
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
ef428f9 to
698dfeb
Compare
Summary
Checklist
3. to review, feature component)stable32)AI (if applicable)