Skip to content

Conversation

@fodinabor
Copy link
Contributor

@fodinabor fodinabor commented Apr 5, 2020

Resolves #5827
Fix #5755
Fix #5599
Fix #4260
Fix #5846

Since #4788 synching WhatsApp Backups or similar files that don't change their name to Nextcloud is horrible, as one is asked how the files should be handled for every single file every day (well - as often the files change..).

This PR adds the option for synced folders how name collisions with updated files should be handled.
The options are (as proposed in #5599):

  • Ask me every time
  • Rename new version
  • Overwrite remote version

image

Disclaimer: probably did not run all tests cleanly and did not update the screenshots, as that seemed nearly impossible on Windows..

@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

@ashpieboop ashpieboop mentioned this pull request Apr 6, 2020
@tobiasKaminsky
Copy link
Member

Welcome on board 🎉

Some very very minor issues.
Other than that is perfect ❤️

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.

I don't like how we treat serialization/deserialization here - it's brittle and the logic is spraed into multiple points of interest.

Also, naming is of a concern here.

return 0;
}

public void setNameCollisionPolicy(String nameCollisionPolicy) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean setCollisionPolicyByName(String collisionPolicyName)? This function name does not make sense - it says that someobdy chooses a name for a collision policy.

I think it refers to the unfornately named NameCollisionPolicy type.

@tobiasKaminsky what do you think? can we fix it?

}

public void setNameCollisionPolicy(String nameCollisionPolicy) {
switch (nameCollisionPolicy) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This conversion could be folded into enum NameCollisionPolicy:

public static NameCollisionPolicy fromName(String policyName) { ... }

@tobiasKaminsky I think the name choosen for this concept is invalid. While here, we could rename it into CollisionPolicyName, so it respects english grammar rules. As it is now - it's just confusing.

@tobiasKaminsky
Copy link
Member

I don't like how we treat serialization/deserialization here - it's brittle and the logic is spraed into multiple points of interest.

As this is mainly c&p from the way I 🙈 handled this on other parts, I am fine to have this the same way for now, and refactor later.

@fodinabor
Copy link
Contributor Author

I tried to make the NameCollisionPolicy / dialog index a bit cleaner and moved the code for this to the fragment, as the selection index to 'NameCollisionPolicy` mapping is only required in this specific dialog.

@nextcloud nextcloud deleted a comment from fodinabor Apr 8, 2020
@nextcloud-android-bot
Copy link
Collaborator

Unit test failed, but no output was generated. Maybe a preliminary stage failed.

@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

@tobiasKaminsky
Copy link
Member

/backport to stable-3.11

@tobiasKaminsky
Copy link
Member

@fodinabor I took the freedom to reformat the code a bit.
We try to have each parameter in a new line, if it fits not in one line (>120 chars).
This is the next time then way more better to read.

@nextcloud-android-bot
Copy link
Collaborator

Unit test failed, but no output was generated. Maybe a preliminary stage failed.

This was referenced Apr 14, 2020
@tobiasKaminsky
Copy link
Member

Rebased and let us merge this tomorrow :-)

@nextcloud-android-bot
Copy link
Collaborator

Unit test failed, but no output was generated. Maybe a preliminary stage failed.

@AndyScherzinger
Copy link
Member

@tobiasKaminsky can you take care of the spotbug counter? ❤️

fodinabor and others added 3 commits April 15, 2020 19:12
Signed-off-by: Joachim Meyer <joachim@joameyer.de>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
@nextcloud-android-bot
Copy link
Collaborator

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

Issues
======
+ Solved 8
           

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

See the complete overview on Codacy

@nextcloud-android-bot
Copy link
Collaborator

Unit test failed, but no output was generated. Maybe a preliminary stage failed.

@nextcloud-android-bot
Copy link
Collaborator

@nextcloud-android-bot
Copy link
Collaborator

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13536.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

Unit test failed, but no output was generated. Maybe a preliminary stage failed.

@nextcloud-android-bot
Copy link
Collaborator

Codacy

384

Lint

TypemasterPR
Warnings9494
Errors11

SpotBugs (new)

Warning TypeNumber
Bad practice Warnings26
Correctness Warnings70
Internationalization Warnings11
Malicious code vulnerability Warnings5
Multithreaded correctness Warnings9
Performance Warnings77
Security Warnings44
Dodgy code Warnings142
Total384

SpotBugs (master)

Warning TypeNumber
Bad practice Warnings26
Correctness Warnings70
Internationalization Warnings11
Malicious code vulnerability Warnings5
Multithreaded correctness Warnings9
Performance Warnings77
Security Warnings44
Dodgy code Warnings141
Total383

@nextcloud-android-bot
Copy link
Collaborator

@tobiasKaminsky tobiasKaminsky merged commit af0b39e into nextcloud:master Apr 16, 2020
@tobiasKaminsky
Copy link
Member

Thanks @fodinabor for this awesome contribution!

@backportbot-nextcloud
Copy link

backport to stable-3.11 in #5883

@piknew
Copy link

piknew commented Apr 22, 2020

Will it fix the issue from #5755 if remote file does not exist yet? It is a case for 100% new file, eg. photo just taken, definitely not stored on remote (server) side yer. However, sync conflict is still reported by client?

@piknew
Copy link

piknew commented Apr 24, 2020

v3.11.1 - not fixed for non-existing files. Strange as it seems to query... directory (not file). Following is apache access log when I click "conflicted file". App queries "getting remote version from server" (again, a file does not exist on server) and apache is reporting:

Apr 25 00:26:46 PKSERVER apache[25696]: *******:443 192.168.10.1 - "PROPFIND /remote.php/webdav/Photos/Camera/ HTTP/1.1" 207 RX:1809 TX:2068 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.11.1"
Apr 25 00:26:46 PKSERVER apache[25708]: *******:443 192.168.10.1 - "PROPFIND /remote.php/webdav/Photos/Camera/ HTTP/1.1" 207 RX:1471 TX:13433 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.11.1"

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.

NextCloud Upload of WhatsApp Backup failed Sync conflict File duplication error auto-upload and WhatsApp backups

7 participants