android icon indicating copy to clipboard operation
android copied to clipboard

#7815 Delayed synchronization

Open BatPio opened this issue 2 years ago • 8 comments

Fixes #7815 Fixes #2323

  • [ ] Tests written, or not not needed Some tests are written. I'm waiting for suggestions on what else can be tested.

Delay configuration:

sync_delay

BatPio avatar Jan 19 '23 21:01 BatPio

Codecov Report

Merging #11278 (3d40c3a) into master (aeb1632) will increase coverage by 0.07%. The diff coverage is 37.20%.

:exclamation: Current head 3d40c3a differs from pull request most recent head 501d1fe. Consider uploading reports for the commit 501d1fe to get more accurate results

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #11278      +/-   ##
============================================
+ Coverage     31.44%   31.52%   +0.07%     
- Complexity     3413     3427      +14     
============================================
  Files           575      577       +2     
  Lines         42018    42146     +128     
  Branches       5660     5664       +4     
============================================
+ Hits          13214    13286      +72     
- Misses        26861    26905      +44     
- Partials       1943     1955      +12     
Impacted Files Coverage Δ
...com/nextcloud/client/database/NextcloudDatabase.kt 100.00% <ø> (ø)
...cloud/client/database/entity/SyncedFolderEntity.kt 0.00% <0.00%> (ø)
...java/com/nextcloud/client/di/ComponentsModule.java 0.00% <ø> (ø)
...in/java/com/nextcloud/client/jobs/FilesSyncWork.kt 21.95% <0.00%> (-0.18%) :arrow_down:
...loud/android/datamodel/FilesystemDataProvider.java 4.39% <0.00%> (-0.10%) :arrow_down:
...oud/android/datamodel/SyncedFolderDisplayItem.java 35.29% <ø> (ø)
...ncloud/android/datamodel/SyncedFolderProvider.java 10.93% <0.00%> (-0.18%) :arrow_down:
...ain/java/com/owncloud/android/db/ProviderMeta.java 100.00% <ø> (ø)
...cloud/android/ui/activity/SyncedFoldersActivity.kt 20.43% <0.00%> (-0.55%) :arrow_down:
.../dialog/SyncedFolderPreferencesDialogFragment.java 0.00% <0.00%> (ø)
... and 11 more

codecov[bot] avatar Jan 20 '23 00:01 codecov[bot]

@AlvaroBrey Thanks for hints! I made fixes

BatPio avatar Jan 29 '23 22:01 BatPio

master-IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/8399-IT-master-22-20

nextcloud-android-bot avatar Apr 24 '23 22:04 nextcloud-android-bot

@BatPio is this still a work in progress or has it been abandoned?

andreapx avatar Oct 18 '23 07:10 andreapx

@JonasMayerDev @alperozturk96

Hi, sorry for delay, I updated my branch to master and now I have a problem with check: "TooManyFunctions - 15/15 - [Class 'SyncedFolderPreferencesDialogFragment' with '15' functions detected. "

Can you give me some suggestions on what can be moved out of this class?

BatPio avatar Aug 04 '24 19:08 BatPio

@JonasMayerDev @alperozturk96

Hi, sorry for delay, I updated my branch to master and now I have a problem with check: "TooManyFunctions - 15/15 - [Class 'SyncedFolderPreferencesDialogFragment' with '15' functions detected. "

Can you give me some suggestions on what can be moved out of this class?

You can use

@Suppress("TooManyFunctions")

this annotation to suppress it, or you can create a new class, e.g. DelaySyncDialogManager and move new functions inside it.

alperozturk96 avatar Aug 05 '24 08:08 alperozturk96

@alperozturk96

Thanks for advice

I couldn't find any example of DialogManager in the project, so I used @Suppress("TooManyFunctions") . I think the presence of showUploadDelayDialog in SyncedFolderPreferencesDialogFragment is acceptable, because they are closely related.

I think MR is ready for CR

BatPio avatar Aug 05 '24 20:08 BatPio

i just wonder what the upper limit for the day value will be? as i guess i may choose everything between 1 to 12 months in days. So for example 31 days may not satisfy all users #just saying :p

i will start using NC after this PR is released :) cheers!

uspecies avatar Aug 11 '24 17:08 uspecies

This functionality is really helpful, thanks for investing the time here @BatPio. I was in the middle of setting up my dev environment to implement exactly this functionality when I saw that you already did the work 🙏 .

@tobiasKaminsky @alperozturk96 what is missing to get this merged?

  1. Merge is blocked because changes were requested by @AlvaroBrey two years ago, but they seem to have been addressed by now. Can this be considered done?
  2. Tests have been added. Are there more required?
  3. Due to this PR being open a long time, there were a lot of merges from master. Do we need a cleanup of the git history on this branch (though non-trivial, due to all the merges from master) or can we leave it like it is?

PhilLab avatar Dec 31 '24 13:12 PhilLab

@PhilLab Right, let's finish the job! :)

@tobiasKaminsky @alperozturk96 I've updated my branch to master and merged my mechanism with the latest changes in FilesSyncWork. My MR is ready for CR.

BatPio avatar Jan 08 '25 21:01 BatPio

@alperozturk96 Hi, thanks for the code review. I have made fixes.

I have rebased my branch to master. Next rebase should be easy, but there is a lot of commits in the history. I hope it is not a problem and they will disappear during merging with squash.

You can continue code review :)

BatPio avatar Jan 10 '25 22:01 BatPio

@alperozturk96

Unfortunately rebase still doesn't work on my branch. Can we update it by merge with commit and after review merge it with squash?

BatPio avatar Jan 13 '25 08:01 BatPio

@ZetaTom @tobiasKaminsky Could you review and test this PR?

alperozturk96 avatar Jan 15 '25 15:01 alperozturk96

@BatPio Thank you so much for the update. Code looks ok to me, but I want to test as well.

How can I test the delay? I can test the auto upload and set the delay, but not sure how to exactly test the delay.

alperozturk96 avatar Jan 15 '25 15:01 alperozturk96

@alperozturk96 Testing is time-consuming.

After setting the auto upload delay for a directory, you need to add a new file to that directory and wait. After the delay time has elapsed, the file should appear on the server. It is important to check that the file has not appeared on the server before the delay time has elapsed. Due to the Android's sync interval, the delay may increase by an additional 15 minutes. In case of a 30-minute delay, the file should appear on server no earlier than after 30 minutes and no later than after 45 minutes.

I tested this with screenshots. Unfortunately, I have no idea how to test this without waiting.

BatPio avatar Jan 15 '25 16:01 BatPio

@alperozturk96

I have adapted my code to the current solution with FilesystemDataProvider. MR is ready for testing

BatPio avatar Feb 06 '25 17:02 BatPio

@tobiasKaminsky @ZetaTom

I tested auto upload seems like okay. Could you please review, especially FilesystemDataProvider.java and FilesSyncWork.kt ?

alperozturk96 avatar Feb 07 '25 15:02 alperozturk96

When reading through the linked issues https://github.com/nextcloud/android/issues/7815 and https://github.com/nextcloud/android/issues/2323 – it seems that if we implement this delay setting at all, then it should be only there when auto upload is set to "Delete after upload". Also, instead of a flexible time picker, we should do it like elsewhere in Nextcloud and have some reasonable presets. E.g.:

  • Upload immediately (default)
  • 15 minutes
  • 30 minutes
  • 1 hour
  • 24 hours
  • 1 week

These presets already seem to cover all the cases brought up in the issues, without detailed time configuration needed.

"Send later" in Nextcloud Mail "Clear status after"-picker in online status
image image

Do you see other solutions here, especially ones which don’t add another customizable setting but just do it automatically? @tobiasKaminsky @alperozturk96 @ZetaTom

jancborchardt avatar Mar 03 '25 09:03 jancborchardt

Re @jancborchardt

When reading through the linked issues #7815 and #2323 – it seems that if we implement this delay setting at all, then it should be only there when auto upload is set to "Delete after upload".

I think this feature also makes a ton of sense without auto deletion. It allows you to clean up the taken photos before they hit the cloud. Think of taking 5 photos of the same scene, where you then immediately delete those where people have their eyes closed, etc...

So it should be available for all upload types

PhilLab avatar Mar 03 '25 10:03 PhilLab

@PhilLab ah, thanks for the note, good point.

Then it should just be changed to the suggested intervals as mentioned.

jancborchardt avatar Mar 03 '25 10:03 jancborchardt

@ZetaTom @jancborchardt Thank you for the code review, I made changes

@ZetaTom You are right, the phrase "Delay file upload" can be misleading. I changed it to "Minimum file age"

@jancborchardt I replaced DurationPicker with a list with fixed values

After combining both ideas: Screenshot_20250319_214900Screenshot_20250319_214929Screenshot_20250319_214942

Since the sync interval in Android is 15 minutes, I think this value is not useful. Instead, I would add values of 6 hours and 3 days

BatPio avatar Mar 19 '25 21:03 BatPio

@alperozturk96 @ZetaTom

I've reworked the UI as suggested by @jancborchardt . Could you please review the changes?

BatPio avatar Mar 25 '25 21:03 BatPio

@tobiasKaminsky @alperozturk96 @ZetaTom could you give this a review? :)

jancborchardt avatar May 12 '25 09:05 jancborchardt

Will review tomorrow

tobiasKaminsky avatar May 12 '25 13:05 tobiasKaminsky

Will review tomorrow @tobiasKaminsky

Hi, I updated my branch to master and resolved the conflicts with the database version. Could you please do a review?

BatPio avatar Aug 11 '25 16:08 BatPio