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 }