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 sure upload is only added once to db #12345

Merged
merged 6 commits into from
Jan 11, 2024

Conversation

JonasMayerDev
Copy link
Collaborator

@JonasMayerDev JonasMayerDev commented Jan 8, 2024

Make sure that upload can not be added twice to db to help with #11974
Should not harm: Why would user want to add upload twice and not update existing one?
For Example, if an upload failed and the user re-uploads, with this pr it updates the existing failed upload with "in progress" to try to upload it again instead of adding the same upload again and causing a conflict next time failed uploads are retried. (See Video)
In addition to that, fixes some issues that occur when duplicates of same upload are in upload list since most functions assume they find only one upload (see uploads tab in video on master)
Screen_recording_20240108_112327.webm
Master
Screen_recording_20240108_112525.webm
This PR

  • Tests written, or not not needed

Copy link
Collaborator

@ZetaTom ZetaTom left a comment

Choose a reason for hiding this comment

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

During my brief tests, this change worked well.

@JonasMayerDev JonasMayerDev force-pushed the make_sure_upload_is_only_added_once_to_db branch from 1f3ac33 to 3024763 Compare January 9, 2024 15:09
@JonasMayerDev JonasMayerDev force-pushed the make_sure_upload_is_only_added_once_to_db branch from 3024763 to 3d3cd15 Compare January 10, 2024 08:53
Copy link

Codacy

Lint

TypemasterPR
Warnings6969
Errors33

SpotBugs

CategoryBaseNew
Bad practice2626
Correctness6969
Dodgy code353353
Experimental22
Internationalization99
Malicious code vulnerability22
Multithreaded correctness99
Performance5454
Security1818
Total542542

Copy link

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

@alperozturk96 alperozturk96 merged commit 5ec3f51 into master Jan 11, 2024
20 checks passed
@delete-merged-branch delete-merged-branch bot deleted the make_sure_upload_is_only_added_once_to_db branch January 11, 2024 08:19
@rloutrel
Copy link

rloutrel commented Jan 25, 2024

Thank you 100 times!

It is nice to provide something to fix this. But I am not sure about what you mean with 'if an upload failed' and the consequences of 'with "in progress" to try to upload it again'.
Actually it does not fail, it is just that the work in the backend takes longer than what the application is waiting to validate the upload at the end, like some post upload processing before sending final Ack (it could also append with smaller document and the interrupted connections of smartphone apps). Therefor no new upload should be done to replace it. It would change the problem from 'infinite' upload loop to an 'infinite' replace loop (better for storage, if we exclude hdd/sdd read/write limitations, but still not sufficient).

Instead of that, the existing file and the file to be uploaded should be compared to evaluate if they are equivalent (size+name+md5+sha256 OR something similar OR some download ID) or some other technique to ensure the job has been previously correctly done.

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

Successfully merging this pull request may close these issues.

4 participants