Skip to content

Fix removed address book items not being synced between federated instances#59312

Merged
icewind1991 merged 6 commits intomasterfrom
calender-sync-delete
Apr 23, 2026
Merged

Fix removed address book items not being synced between federated instances#59312
icewind1991 merged 6 commits intomasterfrom
calender-sync-delete

Conversation

@icewind1991
Copy link
Copy Markdown
Member

Currently deleted address book items aren't send in the sync REPORT response.

This adds the removed items to the REPORT response.

Additionally it adds a --full option to the occ federation:sync-addressbooks command to allow fixing existing cases of deletes not being synced.

@icewind1991 icewind1991 added this to the Nextcloud 34 milestone Mar 30, 2026
@icewind1991 icewind1991 added 3. to review Waiting for reviews feature: carddav Related to CardDAV internals labels Mar 30, 2026
@icewind1991 icewind1991 requested review from ArtificialOwl, CarlSchwan, leftybournes and salmart-dev and removed request for a team March 30, 2026 15:35
Comment thread apps/dav/lib/CardDAV/SyncService.php Outdated
// when doing a full sync, remove any items in the local address book that aren't in the remote one
if (!$syncToken) {
$existingCards = $this->backend->getCards($addressBookId);
$removedCards = array_filter($existingCards, fn (array $card) => !in_array($card['uri'], $received));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Premature approval,
This logic doesn't work in case of truncation, not all the cards are received at each step

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to "mark" all cards at the start of the sync by setting the mtime to null, then at the end delete all cards that haven't been touched by the sync.

@icewind1991 icewind1991 force-pushed the calender-sync-delete branch 2 times, most recently from 85aba8b to 93fe7e3 Compare April 8, 2026 14:01
Comment thread apps/federation/lib/SyncFederationAddressBooks.php Outdated
@hamza221 hamza221 requested a review from kesselb April 15, 2026 11:22
@icewind1991 icewind1991 requested a review from hamza221 April 15, 2026 12:11
Signed-off-by: Robin Appelman <robin@icewind.nl>
…a sync

Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 force-pushed the calender-sync-delete branch from 93fe7e3 to fc11eef Compare April 17, 2026 15:27
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
Copy link
Copy Markdown
Member Author

Fixed an issue with the limit handling of the initial sync where because of a missing ordering some items could be skipped.

Copy link
Copy Markdown
Contributor

@hamza221 hamza221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

$syncToken = $oldSyncToken;
$syncToken = $full ? null : $oldSyncToken;

$book = $this->syncService->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetBookProperties);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Causes a redundant call inside https://github.com/nextcloud/server/blob/master/apps/dav/lib/CardDAV/SyncService.php#L51

Maybe it should be removed inside syncRemoteAddressBook and we pass the addressbook as a parameter ?

Copy link
Copy Markdown
Member

@AndyScherzinger AndyScherzinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@icewind1991
Copy link
Copy Markdown
Member Author

/backport to stable33

@icewind1991
Copy link
Copy Markdown
Member Author

/backport to stable32

@icewind1991 icewind1991 merged commit 379fa54 into master Apr 23, 2026
188 of 196 checks passed
@icewind1991 icewind1991 deleted the calender-sync-delete branch April 23, 2026 18:17
@nextcloud-bot nextcloud-bot mentioned this pull request Apr 27, 2026
@icewind1991
Copy link
Copy Markdown
Member Author

/backport to stable31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews feature: carddav Related to CardDAV internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants