mirror of
https://github.com/sbt/sbt.git
synced 2026-08-31 18:24:30 +02:00
Resets the connection (and sets partial download to false) if the range is not satisfiable by the server (#795)
This commit is contained in:
committed by
Alexandre Archambault
parent
a7605ff900
commit
cf365ea27a
@@ -867,4 +867,30 @@ class CliFetchIntegrationTest extends FlatSpec with CliTestLib {
|
||||
}
|
||||
}
|
||||
|
||||
"Wrong range partial artifact resolve" should "succeed with retry" in withTempDir("tmp_dir") {
|
||||
dir => {
|
||||
def runFetchJunit = {
|
||||
val fetchOpt = FetchOptions(common = CommonOptions(mode = "force", cacheOptions = CacheOptions(cache = dir.getAbsolutePath)))
|
||||
val fetch = Fetch(fetchOpt, RemainingArgs(Seq("junit:junit:4.6"), Seq()))
|
||||
assert(fetch.files0.map(_.getName).toSet
|
||||
.equals(Set("junit-4.6.jar")))
|
||||
val junitJarPath = fetch.files0.map(_.getAbsolutePath()).filter(_.contains("junit-4.6.jar"))
|
||||
.head
|
||||
val junitJarFile = new File(junitJarPath)
|
||||
junitJarFile
|
||||
}
|
||||
|
||||
val originalJunitJar: File = runFetchJunit
|
||||
|
||||
val originalJunitJarContent = FileUtil.readAllBytes(originalJunitJar)
|
||||
|
||||
// Move the jar to partial (but complete) download
|
||||
val newJunitJar: File = new File(originalJunitJar.getAbsolutePath + ".part")
|
||||
originalJunitJar.renameTo(newJunitJar)
|
||||
|
||||
// Run fetch again and it should pass because of retrying on the partial jar.
|
||||
val jar = runFetchJunit
|
||||
assert(FileUtil.readAllBytes(jar).sameElements(originalJunitJarContent))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user