Fix transfer failed msg

This commit is contained in:
tarsin committed 2023-02-18 12:55:59 +08:00
1 parent 145d5e6302
commit 61fd8dc778
1 file changed
+3 -1
@@ -4,11 +4,13 @@ import okhttp3.ResponseBody
import java.io.File
fun ResponseBody.copyToFile(file: File) {
val length = contentLength()
check(length > 0) { "contentLength < 0!" }
val os = file.outputStream()
val channel = os.channel
val source = source()
try {
channel.transferFrom(source, 0, contentLength())
channel.transferFrom(source, 0, length)
} catch (e: Throwable) {
throw e
} finally {