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

Make synced folder init/enable date persistent #4787

Merged

Conversation

ashpieboop
Copy link
Contributor

@ashpieboop ashpieboop commented Nov 3, 2019

As seen in #1150 :

When the app crashes, is not run for some reason, and that files are added in auto upload folders during this downtime, even if the folders were enabled before and successfully synced some files, there are some that get ignored because the sync start time of an auto upload folder is reset when the application restarts.

This pull request fixes this bug/undesirable behavior.

@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from 65f1dd1 to 160c2f3 Compare November 3, 2019 01:03
@nextcloud-android-bot
Copy link
Collaborator

@codecov
Copy link

codecov bot commented Nov 3, 2019

Codecov Report

Merging #4787 into master will increase coverage by 0.13%.
The diff coverage is 30.1%.

@@             Coverage Diff              @@
##             master    #4787      +/-   ##
============================================
+ Coverage     17.51%   17.65%   +0.13%     
  Complexity        3        3              
============================================
  Files           376      377       +1     
  Lines         32385    32406      +21     
  Branches       4569     4580      +11     
============================================
+ Hits           5673     5721      +48     
+ Misses        25797    25765      -32     
- Partials        915      920       +5
Impacted Files Coverage Δ Complexity Δ
...ain/java/com/owncloud/android/db/ProviderMeta.java 84.61% <ø> (ø) 0 <0> (ø) ⬇️
...java/com/nextcloud/client/di/ComponentsModule.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...wncloud/android/files/BootupBroadcastReceiver.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...n/java/com/owncloud/android/jobs/FilesSyncJob.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...a/com/owncloud/android/jobs/AccountRemovalJob.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...va/com/owncloud/android/utils/FilesSyncHelper.java 22.47% <0%> (+2.66%) 0 <0> (ø) ⬇️
...wncloud/android/jobs/MediaFoldersDetectionJob.java 10.09% <100%> (+0.83%) 0 <0> (ø) ⬇️
...oud/android/ui/activity/SyncedFoldersActivity.java 23.97% <22.22%> (+1.18%) 0 <0> (ø) ⬇️
...a/com/owncloud/android/datamodel/SyncedFolder.java 50% <36.84%> (+38.46%) 0 <0> (ø) ⬇️
...ncloud/android/datamodel/SyncedFolderProvider.java 11.86% <40%> (+0.65%) 0 <0> (ø) ⬇️
... and 20 more

@AndyScherzinger
Copy link
Member

@ArisuOngaku Thanks for this PR 🙏

@tobiasKaminsky @mario fancy taking a look/review ❤️ Code-wise it seems fine to me, besides one minor question regarding data migration for existing db entries.

@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from 160c2f3 to f6cace8 Compare November 3, 2019 12:43
@ashpieboop
Copy link
Contributor Author

ashpieboop commented Nov 3, 2019

There you go, disabled folders get enable_date = -1 and enabled get enable_date = System.currentTimeMillis()

This avoids existing enabled folders from uploading old files, which when actually desired, should be satisfied by #4788

@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from f6cace8 to c6e70c6 Compare November 4, 2019 08:14
@nextcloud nextcloud deleted a comment Nov 4, 2019
@nextcloud-android-bot
Copy link
Collaborator

Copy link
Collaborator

@ezaquarii ezaquarii left a comment

Choose a reason for hiding this comment

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

@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from c6e70c6 to 3a44bba Compare November 4, 2019 22:48
@nextcloud nextcloud deleted a comment Nov 4, 2019
@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from 3a44bba to e2acd56 Compare November 4, 2019 22:57
@nextcloud nextcloud deleted a comment Nov 4, 2019
@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from e2acd56 to e22948e Compare November 5, 2019 19:38
@nextcloud nextcloud deleted a comment Nov 5, 2019
@ashpieboop
Copy link
Contributor Author

ashpieboop commented Nov 5, 2019

So I discovered dagger on my last push; I tested my code of course, but still, how can you tell whether dagger is available in a class? I'm not 100% sure for in SyncedFolderProvider and FileContentProvider.

@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from e22948e to 93ea3ff Compare November 5, 2019 20:10
@nextcloud nextcloud deleted a comment Nov 5, 2019
@ashpieboop ashpieboop force-pushed the auto-upload-start-date-persistence branch from 93ea3ff to aec83c9 Compare November 5, 2019 20:20
@AndyScherzinger AndyScherzinger requested review from tobiasKaminsky and ezaquarii and removed request for mario November 13, 2019 10:41
@ashpieboop
Copy link
Contributor Author

Yeah sorry for that, please be sure I learnt from this situation.

@AndyScherzinger
Copy link
Member

Yeah sorry for that, please be sure I learnt from this situation.

Nothing to be sorry for! Just happy about your ping 🥇

@ezaquarii
Copy link
Collaborator

ezaquarii commented Nov 14, 2019 via email

@ezaquarii
Copy link
Collaborator

@tobiasKaminsky @AndyScherzinger @ArisuOngaku I have only 1 minor comment - not sure if this is important so feel free to ignore it. Rest looks LGTM.

Signed-off-by: Alice Gaudon <alice@gaudon.pro>
@ezaquarii
Copy link
Collaborator

ezaquarii commented Nov 15, 2019 via email

@nextcloud-android-bot
Copy link
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/11626.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@nextcloud-android-bot
Copy link
Collaborator

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- src/main/java/com/owncloud/android/datamodel/SyncedFolder.java  1
- src/main/java/com/owncloud/android/providers/FileContentProvider.java  3
         

Complexity decreasing per file
==============================
+ src/main/java/com/owncloud/android/utils/FilesSyncHelper.java  -1
         

See the complete overview on Codacy

@nextcloud nextcloud deleted a comment Nov 15, 2019
Copy link
Collaborator

@ezaquarii ezaquarii left a comment

Choose a reason for hiding this comment

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

LGTM

@nextcloud-android-bot
Copy link
Collaborator

Codacy

306

Lint

TypemasterPR
Warnings5959
Errors00

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings26
Correctness Warnings70
Internationalization Warnings13
Malicious code vulnerability Warnings5
Multithreaded correctness Warnings9
Performance Warnings119
Security Warnings44
Dodgy code Warnings136
Total422

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings26
Correctness Warnings69
Internationalization Warnings13
Malicious code vulnerability Warnings5
Multithreaded correctness Warnings9
Performance Warnings119
Security Warnings44
Dodgy code Warnings138
Total423

@AndyScherzinger
Copy link
Member

@tobiasKaminsky LGTM code-wise from @ezaquarii's and my perspective. Fancy taking a look? ❤️

@tobiasKaminsky
Copy link
Member

I did following test:

  • fresh install with this branch
  • enabled camera folder
  • took some images --> uploaded fine
  • disabled camera folder
  • took some images
  • re-enabled camera folder
    --> nothing happened
  • took a new image --> only this was uploaded

As I understand it, this PR should then also upload those images within the disabled timespan, or?

But how should this work, if we have "only" enabled timestamp?
E.g:
1000s (just to have short timestamps): enable folder
1500s disable folder
1600s take some images
2000s enable folder again: then we search for images that are enabled since 2000s (

if (cursor.getLong(column_index_date_modified) >= enabledTimestampMs / 1000.0) {
)

But instead we would need the 1500s (disabled timestamp), or?
So we would need an "enabled/disabled" state and a "changedTimestamp"?

@ashpieboop
Copy link
Contributor Author

ashpieboop commented Nov 19, 2019

@tobiasKaminsky No, this pull request does not aim to upload files in a synced folder that were created while the folder was disabled. This pull request only aims to correctly upload all files that are created while a synced folder is enabled, even when the app is closed (aka not monitoring changes) and later opened again.

Before this PR, the app effectively resetted this timestamp at each launch, meaning that when it crashed or wasn't started, any file created during this period would never get uploaded even if the synced folder was enabled.

edit: Though that could actually be a design ambiguity of the meaning of what enabled/disabled for a synced folder means. I took it as "don't upload files that are created in this folder while it's down".
Note though that with #4788, this logic should be handled when that setting is enabled (most probably will end up on by default), and I thought that the behavior you're describing (this PR's current behavior) would fit perfectly for when this other PR's setting is disabled.

@tobiasKaminsky
Copy link
Member

Ah, then I misunderstood the idea of it and now it makes sense and this PR fits totally fine.

Thanks for your great enhancement ❤️

@tobiasKaminsky tobiasKaminsky merged commit 94502f6 into nextcloud:master Nov 19, 2019
@ashpieboop
Copy link
Contributor Author

No problem, it's been a pleasure ! ❤️

@tobiasKaminsky
Copy link
Member

As you are a member of nextcloud, you can open up a branch next time directly in this repo, so you do not have to your own.
This makes reviewing/checkout a bit more easier for us :-)

I am looking forward to "see" you next time :-)

@ashpieboop
Copy link
Contributor Author

Alright, thanks for that ! I'm most likely going to work on #4788 now.

@AndyScherzinger AndyScherzinger added this to the Nextcloud App 3.10.0 milestone Nov 19, 2019
tobiasKaminsky added a commit that referenced this pull request Nov 20, 2019
21ef006 Merge pull request #4858 from nextcloud/changeScreenshot
0223085 shorten text a bit
8879179 Drone: update FindBugs results to reflect reduced error/warning count [skip ci]
94502f6 Merge pull request #4787 from ArisuOngaku/auto-upload-start-date-persistence
2110937 Merge pull request #4839 from nextcloud/dependabot/gradle/markwonVersion-4.2.0
f1a0ac5 [tx-robot] updated from transifex
a00677c daily dev 20191119
@ashpieboop ashpieboop deleted the auto-upload-start-date-persistence branch December 9, 2019 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants