|
|
@ -17,6 +17,7 @@ import io.legado.app.lib.webdav.WebDav |
|
|
|
import io.legado.app.utils.* |
|
|
|
import io.legado.app.utils.* |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
|
|
|
|
import kotlinx.coroutines.runBlocking |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
import splitties.init.appCtx |
|
|
|
import splitties.init.appCtx |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
@ -30,6 +31,12 @@ object AppWebDav { |
|
|
|
|
|
|
|
|
|
|
|
var isOk = false |
|
|
|
var isOk = false |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
|
|
|
|
runBlocking { |
|
|
|
|
|
|
|
initConfig() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val rootWebDavUrl: String |
|
|
|
private val rootWebDavUrl: String |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val configUrl = appCtx.getPrefString(PreferKey.webDavUrl)?.trim() |
|
|
|
val configUrl = appCtx.getPrefString(PreferKey.webDavUrl)?.trim() |
|
|
@ -50,8 +57,8 @@ object AppWebDav { |
|
|
|
return "backup${backupDate}.zip" |
|
|
|
return "backup${backupDate}.zip" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
|
|
|
|
suspend fun initConfig() { |
|
|
|
suspend fun initConfig() { |
|
|
|
|
|
|
|
kotlin.runCatching { |
|
|
|
isOk = false |
|
|
|
isOk = false |
|
|
|
val account = appCtx.getPrefString(PreferKey.webDavAccount) |
|
|
|
val account = appCtx.getPrefString(PreferKey.webDavAccount) |
|
|
|
val password = appCtx.getPrefString(PreferKey.webDavPassword) |
|
|
|
val password = appCtx.getPrefString(PreferKey.webDavPassword) |
|
|
@ -60,6 +67,7 @@ object AppWebDav { |
|
|
|
isOk = WebDav(rootWebDavUrl).makeAsDir() && WebDav(bookProgressUrl).makeAsDir() |
|
|
|
isOk = WebDav(rootWebDavUrl).makeAsDir() && WebDav(bookProgressUrl).makeAsDir() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Throws(Exception::class) |
|
|
|
@Throws(Exception::class) |
|
|
|
private suspend fun getWebDavFileNames(): ArrayList<String> { |
|
|
|
private suspend fun getWebDavFileNames(): ArrayList<String> { |
|
|
|