tus-android-client
tus-android-client copied to clipboard
Additional unnecessary call if the file size is divisble by requestPayloadSize
Describe the bug
When trying to upload a file thats exactly divisible by requestPayloadSize
. An additional empty PATCH request will be made that will result in 404.
The cause of it is that in uploadChunk()
method you're finishing connection after bytesRemainingForRequest
is reaching 0
. uploadChunk()
doesn't return -1
at this point.
On the server side the file is already "finished" since all bytes are there, but on the device an additional loop has to be made to receive -1
from uploadChunk()
. But that additional call results in new connection being opened thats when being finished sends an empty body PATCH that results in 404 from the server, since for the server the upload already finished.
I guess a simple fix for that would be to move the openConnection()
inside uploadChunk()
a litte bit lower so that its called only if read
didnt return -1
To Reproduce
- Follow the impl guide.
- Try to upload exactly 10MB file without changing any setup in uploader
Expected behavior No additional call when theres nothing left to upload.
Setup details Please provide following details, if applicable to your situation:
- Any android version
- tus-android-client v0.1.9
- tus-java-client v0.4.2
I'm sorry for only responding now. You are absolutely correct in your analysis. Would you be willing to open a PR for your proposed patch?