Merge pull request #2025 from 821938089/fix-webdav

修复webDav的exists函数对文件夹始终返回false的bug
This commit is contained in:
kunfei
2022-07-05 20:27:13 +08:00
committed by GitHub

View File

@@ -171,7 +171,13 @@ open class WebDav(val path: String, val authorization: Authorization) {
* 文件是否存在
*/
suspend fun exists(): Boolean {
return getWebDavFile() != null
return kotlin.runCatching {
return okHttpClient.newCallResponse {
url(url)
addHeader(authorization.name, authorization.data)
head()
}.code == 200
}.getOrDefault(false)
}
/**