Fix wrong downloaded percentage when server doesn't send content length. Fixes #1019

This commit is contained in:
inorichi
2017-10-05 08:41:28 +02:00
parent 5aae17754f
commit f648940388
3 changed files with 15 additions and 3 deletions

View File

@@ -28,7 +28,11 @@ class Page(
@Transient private var statusSubject: Subject<Int, Int>? = null
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
progress = (100 * bytesRead / contentLength).toInt()
progress = if (contentLength > 0) {
(100 * bytesRead / contentLength).toInt()
} else {
-1
}
}
fun setStatusSubject(subject: Subject<Int, Int>?) {