dependencies: Detect unexpected stream end while downloading

This commit is contained in:
Ilya Matveev
2017-08-09 11:43:43 +07:00
committed by ilmat192
parent 53fedbf55c
commit c7843aa9c7
@@ -163,6 +163,9 @@ class DependencyDownloader(dependenciesRoot: File,
currentBytes += read
read = from.read(buffer)
}
if (currentBytes != totalBytes) {
throw EOFException("The stream closed before end of downloading.")
}
}
}
} catch (e: Throwable) {
@@ -179,7 +182,7 @@ class DependencyDownloader(dependenciesRoot: File,
println("Done.")
if (downloadError != null) {
tmpFile.delete()
throw RuntimeException("Cannot download dependency: $url", downloadError)
throw IOException("Cannot download dependency: $url", downloadError)
}
Files.move(
tmpFile.toPath(),