|
|
@ -19,12 +19,14 @@ import io.legado.app.help.book.BookHelp |
|
|
|
import io.legado.app.help.book.getRemoteUrl |
|
|
|
import io.legado.app.help.book.getRemoteUrl |
|
|
|
import io.legado.app.help.book.isLocal |
|
|
|
import io.legado.app.help.book.isLocal |
|
|
|
import io.legado.app.help.coroutine.Coroutine |
|
|
|
import io.legado.app.help.coroutine.Coroutine |
|
|
|
|
|
|
|
import io.legado.app.lib.webdav.ObjectNotFoundException |
|
|
|
import io.legado.app.model.BookCover |
|
|
|
import io.legado.app.model.BookCover |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule |
|
|
|
import io.legado.app.model.analyzeRule.AnalyzeRule |
|
|
|
import io.legado.app.model.localBook.LocalBook |
|
|
|
import io.legado.app.model.localBook.LocalBook |
|
|
|
import io.legado.app.model.remote.RemoteBookWebDav |
|
|
|
import io.legado.app.model.remote.RemoteBookWebDav |
|
|
|
import io.legado.app.model.webBook.WebBook |
|
|
|
import io.legado.app.model.webBook.WebBook |
|
|
|
|
|
|
|
import io.legado.app.utils.isContentScheme |
|
|
|
import io.legado.app.utils.postEvent |
|
|
|
import io.legado.app.utils.postEvent |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
|
import kotlinx.coroutines.CoroutineScope |
|
|
@ -120,12 +122,19 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
book.origin = BookType.localTag |
|
|
|
book.origin = BookType.localTag |
|
|
|
} else if (remoteBook.lastModify > book.lastCheckTime) { |
|
|
|
} else if (remoteBook.lastModify > book.lastCheckTime) { |
|
|
|
val uri = RemoteBookWebDav.downloadRemoteBook(remoteBook) |
|
|
|
val uri = RemoteBookWebDav.downloadRemoteBook(remoteBook) |
|
|
|
|
|
|
|
book.origin = if (uri.isContentScheme()) uri.toString() else uri.path!! |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
AppLog.put("下载远程书籍<${book.name}>失败", it) |
|
|
|
when (it) { |
|
|
|
|
|
|
|
is ObjectNotFoundException -> { |
|
|
|
|
|
|
|
book.origin = BookType.localTag |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
|
|
AppLog.put("下载远程书籍<${book.name}>失败", it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}.onFinally { |
|
|
|
}.onFinally { |
|
|
|
loadBookInfo(book, false) |
|
|
|
loadBookInfo(book, false) |
|
|
|
} |
|
|
|
} |
|
|
|