fix webdav exists bug

pull/2025/head
821938089 2 years ago
parent ccdcd7c2f3
commit a48cffbba5
  1. 11
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt

@ -171,7 +171,16 @@ open class WebDav(val path: String, val authorization: Authorization) {
* 文件是否存在 * 文件是否存在
*/ */
suspend fun exists(): Boolean { suspend fun exists(): Boolean {
return getWebDavFile() != null return kotlin.runCatching {
val requestPropsStr = DIR.replace("%s", "")
return okHttpClient.newCallResponse {
url(url)
addHeader(authorization.name, authorization.data)
addHeader("Depth", "0")
val requestBody = requestPropsStr.toRequestBody("application/xml".toMediaType())
method("PROPFIND", requestBody)
}.code == 207
}.getOrDefault(false)
} }
/** /**

Loading…
Cancel
Save