This commit is contained in:
Xwite 2023-03-13 12:17:24 +08:00
parent a6165550fb
commit e5f1878cda
2 changed files with 3 additions and 4 deletions

View File

@ -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")

View File

@ -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)
}