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

Additional unnecessary call if the file size is divisble by requestPayloadSize #37

Open
luknow93 opened this issue Feb 13, 2020 · 1 comment
Labels

Comments

@luknow93
Copy link

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

  1. Follow the impl guide.
  2. 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
@luknow93 luknow93 added the bug label Feb 13, 2020
@Acconut
Copy link
Member

Acconut commented Apr 8, 2020

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?

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

No branches or pull requests

2 participants