Skip to content

[Sync] Replace extras Bundle by explicit arguments #1475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 19, 2025

Conversation

rfc2822
Copy link
Member

@rfc2822 rfc2822 commented May 19, 2025

Purpose

Currently, we're using an extras Bundle to encode and pass around sync arguments:

  1. resync type (full resync / resync / no resync) and
  2. upload (initiated by sync framework).

This is not clean because it's not explicit what arguments can be passed over a Bundle and what arguments then are actually used. Also there can be conversion errors when converting from/to a Bundle.

Short description

This PR removes the Bundle and replaces it by explicit parameters.

There's now an explicit ResyncType that explains the two types of re-synchronization.

Checklist

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

@rfc2822 rfc2822 added the refactoring Internal improvement of existing functions label May 19, 2025
@rfc2822 rfc2822 requested a review from Copilot May 19, 2025 10:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the sync managers by removing the outdated extras parameter and replacing it with a ResyncType parameter to standardize re-synchronization logic. The changes span across sync workers, syncers, sync managers, and associated tests, ensuring consistent behavior when triggering re-sync events.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
AccountSettingsModel.kt Updated resyncCalendars and resync calls to use ResyncType instead of boolean flags.
SyncWorkerManager.kt Replaced old extras/resync parameter with ResyncType and renamed upload parameter to syncFrameworkUpload.
BaseSyncWorker.kt Adjusted syncer creation to pass resyncType and syncFrameworkUpload to relevant syncers.
TasksSyncManager.kt, TaskSyncer.kt, JtxSyncer.kt, etc. Updated constructors and factory methods to remove extras and use ResyncType consistently.
SyncManager.kt, ContactsSyncManager.kt, CalendarSyncer.kt, etc. Removed extras parameter in favor of resync, with corresponding documentation updates.
Test Files Updated test setup code to reflect removal of extras and setting resync to null where appropriate.

@rfc2822 rfc2822 self-assigned this May 19, 2025
@rfc2822 rfc2822 changed the title Remove extras parameter from sync managers [Sync] Replace extras Bundle by explicit arguments May 19, 2025
@rfc2822 rfc2822 requested a review from sunkup May 19, 2025 10:28
@rfc2822 rfc2822 marked this pull request as ready for review May 19, 2025 10:28
sunkup
sunkup previously approved these changes May 19, 2025
Copy link
Member

@sunkup sunkup left a comment

Choose a reason for hiding this comment

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

Looks good. I would prefer finding a different name other than ResyncType though - see comment.

package at.bitfire.davdroid.sync

/**
* Used to signal that re-synchronization is requested during a sync.
Copy link
Member

Choose a reason for hiding this comment

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

I know calling it "re-synchronization" is a relic from the sync framework, but I have always found it very confusing, so maybe we can change the term to "sync-size" or something similar?

I don't know of a better way to indicate that this enum and sentence is about the amount of data (partial or total/full) being synchronized. As it stands now, one (including me) might think that it speaks about signaling a new sync request while there is one running already.

Since SyncType would be confusing with the sync data type, we could call the enum SyncSize or SyncAmount instead of ResyncType?

Or just writing: "Used to signal that partial or total re-synchronization is requested during a sync." would help a lot already.

If you don't want to, then we don't need to update it in all places/usages/kdoc, but here would be nice, because, yeah I find the term "re-synchronization" alone very confusing everytime I see it, until I remind myself, that it's actually about partial/full synchronization. 😅

Copy link
Member Author

@rfc2822 rfc2822 May 19, 2025

Choose a reason for hiding this comment

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

I know calling it "re-synchronization" is a relic from the sync framework, but I have always found it very confusing, so maybe we can change the term to "sync-size" or something similar?

No, the normal synchronization is without re-synchronization, so resync = null.

Re-synchronization is not related to the sync framework and really means that the sync algorithm should query (and download) the entries again and not skip synchronization when the sync-token stayed the same since the last sync.

I think SyncSize or amount would make it less clear what it is.

Copy link
Member

Choose a reason for hiding this comment

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

Ah too bad then, but I can see there could also be confusion with the other names.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in DAVx⁵ Releases May 19, 2025
@rfc2822 rfc2822 merged commit eeb94d4 into main-ose May 19, 2025
7 checks passed
@rfc2822 rfc2822 deleted the sync-manager-no-extras branch May 19, 2025 13:37
@github-project-automation github-project-automation bot moved this from In Progress to Done in DAVx⁵ Releases May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Internal improvement of existing functions
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants