-
Notifications
You must be signed in to change notification settings - Fork 95
Scale read-timeout on chunk-upload file assembly #709
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
Conversation
Set read timeout for the move-method that assembles chunk-uploads on the server to 3 minutes per GB between 30 seconds and 30 minutes, consistent with Nextcloud-dektop. Signed-off-by: M. Thees <m.thees@intempestatem.eu>
4a6c62d to
1f69428
Compare
src/main/java/com/owncloud/android/lib/resources/files/ChunkedFileUploadRemoteOperation.java
Outdated
Show resolved
Hide resolved
| moveMethod.addRequestHeader(E2E_TOKEN, token); | ||
| } | ||
| int moveResult = client.executeMethod(moveMethod); | ||
| int moveResult = client.executeMethod(moveMethod, CalcAssembleTimeout(file), -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For -1 can you introduce a const, e.g. DO_NOT_CHANGE_DEFAULT, so that when reading the code one directly knows that this value does not change connection timeout.
| final double threeMinutes = 3.0 * 60 * 1000; | ||
| final int thirtySeconds = 30 * 1000; | ||
| final int thirtyMinutes = 30 * 60 * 1000; | ||
| int AssembleReadTimeout = Math.max(thirtySeconds , Math.min((int)(threeMinutes * file.length() / 1e9) , thirtyMinutes) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| int AssembleReadTimeout = Math.max(thirtySeconds , Math.min((int)(threeMinutes * file.length() / 1e9) , thirtyMinutes) ); | |
| return Math.max(thirtySeconds , Math.min((int)(threeMinutes * file.length() / 1e9) , thirtyMinutes) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also suggest extracting file.length() / 1e9 into a new variable named fileSizeInGb to make it easier to read and make the algorithm clearer.
|
@minfaer thanks for your PR 🎉 Line 73 in fba3a49
Different file sizes:
If you do not have time, then we will take care of it :) |
| } | ||
|
|
||
| private int CalcAssembleTimeout(File file) { | ||
| final double threeMinutes = 3.0 * 60 * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be a double, an int should work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original version, this was a double to prevent threeMinutes * file.length() / 1e9 from truncating to full Gb, but by declaring fileSizeInGb as double, this has indeed become unnecessary.
| final double threeMinutes = 3.0 * 60 * 1000; | ||
| final int thirtySeconds = 30 * 1000; | ||
| final int thirtyMinutes = 30 * 60 * 1000; | ||
| int AssembleReadTimeout = Math.max(thirtySeconds , Math.min((int)(threeMinutes * file.length() / 1e9) , thirtyMinutes) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also suggest extracting file.length() / 1e9 into a new variable named fileSizeInGb to make it easier to read and make the algorithm clearer.
|
Sorry for the close and reopen, my fingers slipped 🤦 I've added a couple of minor comments. Thanks for your contribution! |
3d9ea97 to
60988c0
Compare
Co-authored-by: Tobias Kaminsky <tobias@nextcloud.com> Signed-off-by: M. Thees <m.thees@intempestatem.eu>
Signed-off-by: M. Thees <m.thees@intempestatem.eu>
60988c0 to
415acf0
Compare
|
Thank You @tobiasKaminsky and @AlvaroBrey for Your feedback! I implemented your suggestionsand am looking into writing the unit-tests. |
Codecov Report
@@ Coverage Diff @@
## master #709 +/- ##
==========================================
- Coverage 44.54% 44.49% -0.05%
==========================================
Files 154 154
Lines 6174 6180 +6
Branches 813 813
==========================================
Hits 2750 2750
- Misses 3003 3009 +6
Partials 421 421
|
|
Thanks @minfaer for this suggested patch! |
|
I added tests and once CI is passed, we can merge it. |
Lint
SpotBugs (new)
SpotBugs (master)
|
|
stable-IT test failed: https://www.kaminsky.me/nc-dev/library-integrationTests/560-IT-stable-09-37 |
Checked this out locally, nothing to worry about. Thanks for your contribution @minfaer ! |
|
🎉 |
Fix nextcloud/android#5609
Fix nextcloud/android#8134
This is a fix for nextcloud/android#5609 as proposed in #696.
It works by setting the read timeout for the move-method that assembles chunk-uploads on the server to 3 minutes per GB between 30 seconds and 30 minutes, consistent with Nextcloud-dektop.