Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -29,6 +29,7 @@ import io.legado.app.help.http.Cronet
|
|||||||
import io.legado.app.help.http.ObsoleteUrlFactory
|
import io.legado.app.help.http.ObsoleteUrlFactory
|
||||||
import io.legado.app.help.http.okHttpClient
|
import io.legado.app.help.http.okHttpClient
|
||||||
import io.legado.app.help.source.SourceHelp
|
import io.legado.app.help.source.SourceHelp
|
||||||
|
import io.legado.app.help.storage.Backup
|
||||||
import io.legado.app.model.BookCover
|
import io.legado.app.model.BookCover
|
||||||
import io.legado.app.utils.defaultSharedPreferences
|
import io.legado.app.utils.defaultSharedPreferences
|
||||||
import io.legado.app.utils.getPrefBoolean
|
import io.legado.app.utils.getPrefBoolean
|
||||||
@@ -69,6 +70,7 @@ class App : Application() {
|
|||||||
}
|
}
|
||||||
RuleBigDataHelp.clearInvalid()
|
RuleBigDataHelp.clearInvalid()
|
||||||
BookHelp.clearInvalidCache()
|
BookHelp.clearInvalidCache()
|
||||||
|
Backup.clearCache()
|
||||||
//初始化简繁转换引擎
|
//初始化简繁转换引擎
|
||||||
when (AppConfig.chineseConverterType) {
|
when (AppConfig.chineseConverterType) {
|
||||||
1 -> ChineseUtils.preLoad(true, TransType.TRADITIONAL_TO_SIMPLE)
|
1 -> ChineseUtils.preLoad(true, TransType.TRADITIONAL_TO_SIMPLE)
|
||||||
|
|||||||
@@ -175,6 +175,13 @@ interface BookSourceDao {
|
|||||||
@get:Query("select * from book_sources order by customOrder asc")
|
@get:Query("select * from book_sources order by customOrder asc")
|
||||||
val all: List<BookSource>
|
val all: List<BookSource>
|
||||||
|
|
||||||
|
@get:Query(
|
||||||
|
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||||
|
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
||||||
|
from book_sources order by customOrder asc"""
|
||||||
|
)
|
||||||
|
val allPart: List<BookSourcePart>
|
||||||
|
|
||||||
@get:Query("select * from book_sources where enabled = 1 order by customOrder")
|
@get:Query("select * from book_sources where enabled = 1 order by customOrder")
|
||||||
val allEnabled: List<BookSource>
|
val allEnabled: List<BookSource>
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ object BookHelp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileUtils.delete(ArchiveUtils.TEMP_PATH)
|
FileUtils.delete(ArchiveUtils.TEMP_PATH)
|
||||||
|
val filesDir = appCtx.filesDir
|
||||||
|
FileUtils.delete("$filesDir/shareBookSource.json")
|
||||||
|
FileUtils.delete("$filesDir/shareRssSource.json")
|
||||||
|
FileUtils.delete("$filesDir/books.json")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,11 @@ object SourceHelp {
|
|||||||
appDb.bookSourceDao.maxOrder > 99999
|
appDb.bookSourceDao.maxOrder > 99999
|
||||||
|| appDb.bookSourceDao.minOrder < -99999
|
|| appDb.bookSourceDao.minOrder < -99999
|
||||||
) {
|
) {
|
||||||
appDb.bookSourceDao.all.forEachIndexed { index, bookSource ->
|
val sources = appDb.bookSourceDao.allPart
|
||||||
appDb.bookSourceDao.upOrder(bookSource.bookSourceUrl, index)
|
sources.forEachIndexed { index, bookSource ->
|
||||||
|
bookSource.customOrder = index
|
||||||
}
|
}
|
||||||
|
appDb.bookSourceDao.upOrder(sources)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ object Backup {
|
|||||||
val backupPath: String by lazy {
|
val backupPath: String by lazy {
|
||||||
appCtx.filesDir.getFile("backup").createFolderIfNotExist().absolutePath
|
appCtx.filesDir.getFile("backup").createFolderIfNotExist().absolutePath
|
||||||
}
|
}
|
||||||
val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}backup.zip"
|
val zipFilePath = "${appCtx.externalFiles.absolutePath}${File.separator}tmp_backup.zip"
|
||||||
|
|
||||||
private val backupFileNames by lazy {
|
private val backupFileNames by lazy {
|
||||||
arrayOf(
|
arrayOf(
|
||||||
@@ -166,6 +166,7 @@ object Backup {
|
|||||||
paths[i] = backupPath + File.separator + paths[i]
|
paths[i] = backupPath + File.separator + paths[i]
|
||||||
}
|
}
|
||||||
FileUtils.delete(zipFilePath)
|
FileUtils.delete(zipFilePath)
|
||||||
|
FileUtils.delete(zipFilePath.replace("tmp_", ""))
|
||||||
val backupFileName = if (AppConfig.onlyLatestBackup) {
|
val backupFileName = if (AppConfig.onlyLatestBackup) {
|
||||||
"backup.zip"
|
"backup.zip"
|
||||||
} else {
|
} else {
|
||||||
@@ -188,6 +189,7 @@ object Backup {
|
|||||||
AppWebDav.backUpWebDav(zipFileName)
|
AppWebDav.backUpWebDav(zipFileName)
|
||||||
}
|
}
|
||||||
FileUtils.delete(backupPath)
|
FileUtils.delete(backupPath)
|
||||||
|
FileUtils.delete(zipFilePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,4 +230,9 @@ object Backup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearCache() {
|
||||||
|
FileUtils.delete(backupPath)
|
||||||
|
FileUtils.delete(zipFilePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user