-
-
Notifications
You must be signed in to change notification settings - Fork 90
Provide collection to SyncManager #881
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
Provide collection to SyncManager #881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I like the new approach without that many sub-functions.
8297806
to
42cb4cf
Compare
- added KDoc - SyncManager can never handle address book authority (content authority for contacts is contacts authority) - moved @UsesThreadContextClassLoader to respective sync manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Do you think it would be possible to generalize the process of creating/updating/deleting collections, maybe with an interface or by having the code in `Syncer' and just provide implementation details in the sub-classes? Would be nice if the same code wouldn't be there three times.
- Can you please re-base/merge the latest changes? I changed the
Syncer
s to use DI.
app/src/androidTestOse/kotlin/at/bitfire/davdroid/sync/SyncManagerTest.kt
Outdated
Show resolved
Hide resolved
Maybe, I will see what I can do :) |
It's hard. I have divided the process into 5 stages:
I tried dividing the process into smaller methods in their respective resource type syncers, which are then called one after another in the base syncer. This only makes the process more complicated and yields more duplicated code. Using an interface with decoratored classes only complicates everything even more. The problem are the subtle differences between the resource types. I feel that the easiest way to combine all resource types in one process is to throw them all in one method (sync in base syncer) with a lot of if/else statements deciding the subtleties. It would complicate the sync process a little bit more, but we would get rid of the duplicated code and could drop the specific syncer implementations. That is, we would have one (non-abstract) Syncer, which we'd supply with the authority to be synced. At the moment we also pass the authority to the sync method. So there might actually not be a good gain in having multiple different syncers. I suggest we try merging the different sync step implementations of the syncers in the syncer, passing the authority along as construction argument and let this one concrete syncer instance handle the whole process for all resource types. In a new PR though. @rfc2822 What do you think? Maybe should have a call about it :) |
👍🏻 As discussed, to be followed up by #896 |
Purpose
Provides database Collection to SyncManager. This is a prerequisite for #588 , #876 and #878
Short description
Provide collection to
CalendarSyncManager
ContactsSyncManager
JtxSyncManager
TasksSyncManager
by rewriting
sync
method in respective syncer classesand finally provide collection to
SyncManager
.Also:
TestSyncManager
Checklist