-
Notifications
You must be signed in to change notification settings - Fork 302
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
Incomplete downloads are not detected #2841
Comments
Regarding the code for resuming downloads that is already implemented: Two sections of code that look suspicious to me: coursier/modules/cache/jvm/src/main/scala/coursier/cache/CacheUrl.scala Lines 217 to 225 in ef2b102
Here, the condition startOver = isPartial && !hasMatchingHeader seems not general enough. If the client sends a request for a partial download, but the server responds with a code different from 206/416, the download needs to start-over as well (or it needs to be treated as non-partial). In other words, isPartial needs to account for the intent of the request, rather than looking at the response code.
coursier/modules/cache/jvm/src/main/scala/coursier/cache/CacheUrl.scala Lines 341 to 350 in ef2b102
Here Coursier checks whether the opened connection refers to a partial download and then proceeds to follow redirects. Ideally, this check should be done after following redirects though. |
When the transmission is interrupted while downloading a file without checksums, the partial file ends up in the cache. Coursier does not detect that the download is incomplete. This can happen due to network outages or server timeouts, for example.
Steps to reproduce locally
.part
suffix is removed from the file name.(Tested with coursier-cache_2.13:2.1.2 and OpenJDK 20.0.2 targeting Java 8.)
Solutions
A basic fix would consist of validating the file size in Downloader#Blocking.doDownload based on the
content-length
of the connection, so that at least the error does not go unnoticed.A more advanced fix would try to resume the partial download.
There seems to be some code in place for partial downloads already. To which extent is this supported?
There is also some code for checking the file size that produces a
WrongLength
artifact error, but it does not regulary seem to be invoked, except in case the file already exists and is locked.The text was updated successfully, but these errors were encountered: