From fe8c681064054ef5bbdcd2ddf8b15b25225e3be2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 17 Sep 2019 17:14:53 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/lib/webdav/WebDav.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt index 225850113..424c0d13c 100644 --- a/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt +++ b/app/src/main/java/io/legado/app/lib/webdav/WebDav.kt @@ -21,6 +21,7 @@ import java.util.* class WebDav @Throws(MalformedURLException::class) constructor(url: String) { + private val okHttpClient = HttpHelper.client private val url: URL = URL(null, url, Handler) private var httpUrl: String? = null @@ -36,10 +37,9 @@ constructor(url: String) { return field } - private val okHttpClient = HttpHelper.client + fun getPath() = url.toString() - val path: String - get() = url.toString() + fun getHost() = url.host private val inputStream: InputStream? get() = getUrl()?.let { url -> @@ -56,9 +56,6 @@ constructor(url: String) { return null } - val host: String - get() = url.host - private fun getUrl(): String? { if (httpUrl == null) { val raw = url.toString().replace("davs://", "https://").replace("dav://", "http://") @@ -111,7 +108,6 @@ constructor(url: String) { return parseDir(body.string()) } } - } return ArrayList() } @@ -194,9 +190,7 @@ constructor(url: String) { */ fun downloadTo(savedPath: String, replaceExisting: Boolean): Boolean { if (File(savedPath).exists()) { - if (!replaceExisting) { - return false - } + if (!replaceExisting) return false } val inputS = inputStream ?: return false File(savedPath).writeBytes(inputS.readBytes()) @@ -225,7 +219,6 @@ constructor(url: String) { /** * 执行请求,获取响应结果 - * * @param requestBuilder 因为还需要追加验证信息,所以此处传递Request.Builder的对象,而不是Request的对象 * @return 请求执行的结果 */