fix #2870
This commit is contained in:
@@ -2,7 +2,6 @@ package io.legado.app.lib.webdav
|
||||
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.Server.WebDavConfig
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import okhttp3.Credentials
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.StandardCharsets
|
||||
@@ -24,7 +23,7 @@ data class Authorization(
|
||||
}
|
||||
|
||||
constructor(serverID: Long?): this("","") {
|
||||
serverID ?: throw NoStackTraceException("Unexpected server ID")
|
||||
serverID ?: throw WebDavException("Unexpected server ID")
|
||||
appDb.serverDao.get(serverID)?.getWebDavConfig()?.run {
|
||||
data = Credentials.basic(username, password, charset)
|
||||
} ?: throw WebDavException("Unexpected WebDav Authorization")
|
||||
|
||||
@@ -329,10 +329,10 @@ object LocalBook {
|
||||
// 兼容旧版链接
|
||||
val webdav: WebDav = kotlin.runCatching {
|
||||
WebDav.fromPath(webDavUrl)
|
||||
}.onFailure {
|
||||
}.getOrElse {
|
||||
AppWebDav.defaultBookWebDav
|
||||
?: throw WebDavException("Unexpected defaultBookWebDav")
|
||||
}.getOrThrow()
|
||||
}
|
||||
val uri = runBlocking {
|
||||
saveBookFile(webdav.downloadInputStream(), localBook.originName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user