No more content length validation
This commit is contained in:
1 parent
b0f0686821
commit
5d4f544b94
2 files changed
+8
-10
No files matched your search
@@ -46,7 +46,7 @@ class CronetRequest {
|
||||
lateinit var onResponse: CronetRequest.(UrlResponseInfo) -> Unit
|
||||
lateinit var request: UrlRequest
|
||||
lateinit var daemonCont: Continuation<Boolean>
|
||||
lateinit var readerCont: Continuation<Long>
|
||||
lateinit var readerCont: Continuation<Unit>
|
||||
val callback = object : UrlRequest.Callback() {
|
||||
override fun onRedirectReceived(req: UrlRequest, info: UrlResponseInfo, url: String) {
|
||||
logcat(tag = TAG) { "Redirected to $url" }
|
||||
@@ -63,8 +63,7 @@ class CronetRequest {
|
||||
}
|
||||
|
||||
override fun onSucceeded(req: UrlRequest, info: UrlResponseInfo) {
|
||||
val length = info.receivedByteCount
|
||||
readerCont.resume(length)
|
||||
readerCont.resume(Unit)
|
||||
daemonCont.resume(true)
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ inline fun cronetRequest(url: String, referer: String? = null, conf: UrlRequest.
|
||||
}.apply(conf).build()
|
||||
}
|
||||
|
||||
suspend inline fun CronetRequest.awaitBodyFully(crossinline callback: (ByteBuffer) -> Unit): Long {
|
||||
suspend inline fun CronetRequest.awaitBodyFully(crossinline callback: (ByteBuffer) -> Unit) {
|
||||
val buffer = pool.borrow()
|
||||
return try {
|
||||
suspendCancellableCoroutine { cont ->
|
||||
|
||||
@@ -160,25 +160,24 @@ class SpiderDen(mGalleryInfo: GalleryInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun saveResponseMeta(index: Int, ext: String, length: Long, fops: suspend (UniFile) -> Long): Boolean {
|
||||
private suspend fun saveResponseMeta(index: Int, ext: String, length: Long, fops: suspend (UniFile) -> Unit): Boolean {
|
||||
suspend fun realFops(f: UniFile) = fops(f).apply {
|
||||
if (ext.lowercase() == "gif") {
|
||||
f.openFileDescriptor("rw").use { rewriteGifSource2(it.fd) }
|
||||
}
|
||||
}
|
||||
findDownloadFileForIndex(index, ext)?.run {
|
||||
return realFops(this) == length
|
||||
realFops(this)
|
||||
return true
|
||||
}
|
||||
|
||||
// Read Mode, allow save to cache
|
||||
if (mode == SpiderQueen.MODE_READ) {
|
||||
val key = getImageKey(mGid, index)
|
||||
var received = 0L
|
||||
sCache.suspendEdit(key) {
|
||||
return sCache.suspendEdit(key) {
|
||||
metadata.toFile().writeText(ext)
|
||||
received = realFops(UniFile.fromFile(data.toFile())!!)
|
||||
realFops(UniFile.fromFile(data.toFile())!!)
|
||||
}
|
||||
return received == length
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user