From 60fb0d385de495d880b6634323c4dfe60cd6c479 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 8 May 2021 12:34:53 +0800 Subject: [PATCH] =?UTF-8?q?WebDav=E5=88=9B=E5=BB=BA=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E6=B7=BB=E5=8A=A0try=E9=98=B2=E6=AD=A2=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/lib/webdav/WebDav.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 36713320f..7a8e438ae 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 @@ -144,19 +144,20 @@ class WebDav(urlStr: String) { /** * 根据自己的URL,在远程处创建对应的文件夹 - * * @return 是否创建成功 */ suspend fun makeAsDir(): Boolean { val url = httpUrl val auth = HttpAuth.auth if (url != null && auth != null) { - okHttpClient.newCall { - url(url) - method("MKCOL", null) - addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) - } - return true + //防止报错 + return kotlin.runCatching { + okHttpClient.newCall { + url(url) + method("MKCOL", null) + addHeader("Authorization", Credentials.basic(auth.user, auth.pass)) + } + }.isSuccess } return false }