-
Notifications
You must be signed in to change notification settings - Fork 72
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
Error in checksum extension after cancelled requests #63
Comments
This behavior is by design and by the specification. "Once the entire request has been received, the Server MUST verify the uploaded chunk against the provided checksum using the specified algorithm." (https://tus.io/protocols/resumable-upload.html#checksum). If the client disconnects, then the entire request has not been received. Doing it the way you propose would break resumability of all uploads that use the checksum extension as the checksum will never match if the client disconnects. I don't really follow your steps. Number 6 should not happen if you follow the protocol and continue the upload (chunked or not) from the server's offset. Do you have a reproducible example where this happens? |
Hello,
This is the exact problem i get. Current implementation does not discard uncompleted request data when cancellationToken raises cancel flag:
Data, that is already written stays on disk and checksum extension method is not invoked. I don't have an example to illustrate problem on hand (we use custom store), but will try to construct something. |
The thing is that it's not supposed to discard data if the client disconnects. Basically the sequence of events is something like below. Remember that "chunks" have no special meaning in tus. It is just a workaround for proxies, hardware limitations etc. So let's say we have a 100 MB file that we split into 1 MB chunks. The client would split the file in 100 chunks, calculate the checksum of each chunk and then start the uploading. Client: Here is my first chunk with checksum X. Checksums would basically be worthless if the data was discarded at each disconnect as there will never be a checksum that matches in that case. It would just be far easier to say that all client disconnects should discard the last chunk, which is not the case. |
After reading the spec again I find some of the parts regarding chunks and checksum to be a bit contradicting so I have created a issue over at the protocol's github: tus/tus-resumable-upload-protocol#143 |
Hello, It seems correct for last (uncompleted) chunk to be discarded when checksum extension is in use. It makes sense, since HEAD response does not contain any data to sync client and server in this regard. And it is possible that upload can be continued from other client instance (unexpected shutdown), or after web page reload. |
I get your argument and can agree to a certain degree. I will have to wait for an answer in the linked issue before taking actions on this issue as it might break stuff for other clients. If you need to move forward I would suggest disabling checksums on your server as checksums bring very little (close to nothing IMO) to the table if the server runs HTTPS. HTTPS already have a checksum implementation of sorts since it's encrypted. If the data is modified during transfer the server will not be able to decrypt the data and hence the request will fail. Disable checksums by removing the
Side note: I looked at the client you're using. It's unfortunate that it forces you to use chunks as you are missing the key feature of tus, namely streamed uploads, where only a single HTTP request is used. Not much to do about it though (except writing your own ;) ). |
Confirmed as a bug by the Tus team. I will make a patch and release a new version as soon as possible. Until then, use the work around in the above comment. |
Hello!
Unfortunately, we have hardware VPN with GOST encryption somewhere in the middle, and large requests are just dropped. So chunks are a nessisity.
For now, I made a dirty fix, moving checksum calculation before cancellation token check in WriteFileHandler
Looking forward to it. Thank you againg for your time! |
Thanks for your patience on this issue! I have pushed a fix now and a new version should be on nuget shortly. :)
I see! Doing chunks without the checksum extension would give you slightly better resumability as the last chunk does not need to be discarded but could be continued where it was left of. Not sure how much of an improvement that would be though if you are already using fairly small chunks.
My solution is actually close to that so I wouldn't call it a dirty fix ;)
No worries! Thanks for using tusdotnet! |
@mrandrewer Feel free to close this issue once you have confirmed that it's working in your setup. |
Hello! |
Checksum verification does not occur if request was cancelled, this leads to verification error on next chunk upload.
Steps to reproduce with TusDiskStore:
Protocol states that "The Server SHOULD always attempt to store as much of the received data as possible.", but it seems more viable to discard uncompleted chunk when using checksum extension.
The text was updated successfully, but these errors were encountered: