Skip to content
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

Do not require internet connection for worker if only local subscriptions are used #389

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from

Conversation

ArnyminerZ
Copy link
Member

@ArnyminerZ ArnyminerZ commented Aug 14, 2024

Purpose

See #385, in some rare cases where INTERNET permission is not always granted, if trying to synchronize subscriptions for local files, they don't run since they wait until a network connection is available.

Short description

There are now two workers, now one that only syncs local collections, and another one that synchronizes the network-dependant subscriptions.

This condition is checked with the scheme of the url. If it starts with "http" (which includes "https"), it's a network subscription, otherwise it's local.

This condition is passed to the BaseSyncWorker through a new argument called filter.

Migration is only performed by the NetworkSyncWorker, so ONLY_MIGRATE is always false for LocalSyncWorker. Note that since there are now two workers, they are scheduled, cancelled and their status is obtained through the companion functions of BaseSyncWorker.

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.

Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
@ArnyminerZ ArnyminerZ requested a review from sunkup August 14, 2024 10:03
@ArnyminerZ ArnyminerZ added the enhancement New feature or request label Aug 14, 2024
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.

Hmm, so this will only work if the person has only local ics files, right? Feels a bit off to me, to add this then. It would be a broken enhancement kind of.

I would rather do this properly and I think it's not that hard either if we had two sync workers. A LocalSyncWorker without network requirement and a NetworkSyncWorker, which then maybe both extend from an abstract base sync worker that contains the code in common.

What do you think?

@ArnyminerZ
Copy link
Member Author

Yeah, that would be more proper, but I didn't want to do such a big change. Do we want to do this? I think it will be even useful for DAVx⁵ in the future.

@sunkup
Copy link
Member

sunkup commented Aug 16, 2024

Why did you not want to make a big change? There is no problem with big changes if they are well reasoned and we discuss them before they are implemented. I actually don't think it's that big of a change, but maybe I am bad at estimating. If it becomes too much maybe split it up in two PRs. One for refactoring, one for the feature / enhancement.

Do you want to give it a try? My focus lies with DAVx5 at the moment as I wrote already, but I can review at some point 👍

@ArnyminerZ
Copy link
Member Author

Okay, I'll give it a try and see if it's simple enough, otherwise I'll try to split it. You have worked more than me on workers, so this will also be a good opportunity to develop with them a bit.

Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
Signed-off-by: Arnau Mora Gras <[email protected]>
@ArnyminerZ ArnyminerZ requested a review from sunkup August 17, 2024 10:21
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 promising and seems to work already, but there is a failing test and it's not really clear which worker does what.

I think we should rename SyncWorker to NetworkSyncWorker or something similar for clarity and also add some short KDoc to the worker classes, explaining what their purpose is and what for example the new "filter" property is for.

Also would be nice with an updated PR description, which gives an overview of the changes. :)

@ArnyminerZ ArnyminerZ requested a review from sunkup August 20, 2024 12:37
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.

I am not really a fan of the anonymous filter functions in the class constructors. Does not matter if it is more verbose, but maybe there is a more descriptive and clear way of doing it?

What about the periodic sync worker ? I am guessing people who use syncthing, probably still want to synchronize their local ics files periodically too ... Could be a new feature in a new PR, but we could add it here too. What do you think?

@ArnyminerZ
Copy link
Member Author

Yup, I agree with everything. I'll think about it for a bit, and see which approach I find for the filtering. Since the base sync class is open, maybe we can add an open function for the filter, instead of anonimizing it and then overriding the method on the upper class.

For the sync, yup, periodic workers should absolutely be working IMO. Even better if we could somehow schedule it to observe changes on the local filesystem, though I don't know if it's possible.

@sunkup
Copy link
Member

sunkup commented Aug 27, 2024

For the sync, yup, periodic workers should absolutely be working IMO.

Add it to this PR then :)

Even better if we could somehow schedule it to observe changes on the local filesystem, though I don't know if it's possible.

Nice idea, but that should definetly go in a separate PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not require internet connection for worker if only local subscriptions are used
2 participants