pull/1822/head
kunfei 3 years ago
parent e25d377602
commit b02fa75c1e
  1. 16
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt

@ -157,11 +157,13 @@ class WebDav(urlStr: String, val authorization: Authorization) {
//防止报错 //防止报错
return kotlin.runCatching { return kotlin.runCatching {
if (!exists()) { if (!exists()) {
okHttpClient.newCallResponseBody { okHttpClient.newCallResponse {
url(url) url(url)
method("MKCOL", null) method("MKCOL", null)
addHeader("Authorization", authorization.data) addHeader("Authorization", authorization.data)
}.close() }.body?.string()?.let {
Log.d("webDav/makAsDir", it)
}
} }
}.onFailure { }.onFailure {
AppLog.put(it.localizedMessage) AppLog.put(it.localizedMessage)
@ -207,7 +209,7 @@ class WebDav(urlStr: String, val authorization: Authorization) {
put(fileBody) put(fileBody)
addHeader("Authorization", authorization.data) addHeader("Authorization", authorization.data)
}.body?.string()?.let { }.body?.string()?.let {
Log.d("webDav", it) Log.d("webDav/upload", it)
} }
}.onFailure { }.onFailure {
it.printOnDebug() it.printOnDebug()
@ -219,11 +221,15 @@ class WebDav(urlStr: String, val authorization: Authorization) {
val fileBody = byteArray.toRequestBody(contentType.toMediaType()) val fileBody = byteArray.toRequestBody(contentType.toMediaType())
val url = httpUrl ?: return false val url = httpUrl ?: return false
return kotlin.runCatching { return kotlin.runCatching {
okHttpClient.newCallResponseBody { okHttpClient.newCallResponse {
url(url) url(url)
put(fileBody) put(fileBody)
addHeader("Authorization", authorization.data) addHeader("Authorization", authorization.data)
}.close() }.body?.string()?.let {
Log.d("webDav/upload", it)
}
}.onFailure {
it.printOnDebug()
}.isSuccess }.isSuccess
} }

Loading…
Cancel
Save