Change extension repo to extension store and add support for newer extension index format (#3349)
This commit is contained in:
+6
-11
@@ -4,8 +4,7 @@ import eu.kanade.domain.source.service.SourcePreferences
|
||||
import logcat.LogPriority
|
||||
import mihon.core.migration.Migration
|
||||
import mihon.core.migration.MigrationContext
|
||||
import mihon.domain.extensionrepo.exception.SaveExtensionRepoException
|
||||
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
|
||||
import mihon.domain.extension.repository.ExtensionStoreRepository
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
|
||||
@@ -14,18 +13,14 @@ class TrustExtensionRepositoryMigration : Migration {
|
||||
|
||||
override suspend fun invoke(migrationContext: MigrationContext): Boolean = withIOContext {
|
||||
val sourcePreferences = migrationContext.get<SourcePreferences>() ?: return@withIOContext false
|
||||
val extensionRepositoryRepository =
|
||||
migrationContext.get<ExtensionRepoRepository>() ?: return@withIOContext false
|
||||
val repository = migrationContext.get<ExtensionStoreRepository>() ?: return@withIOContext false
|
||||
for ((index, source) in sourcePreferences.extensionRepos.get().withIndex()) {
|
||||
try {
|
||||
extensionRepositoryRepository.upsertRepo(
|
||||
source,
|
||||
"Repo #${index + 1}",
|
||||
null,
|
||||
source,
|
||||
"NOFINGERPRINT-${index + 1}",
|
||||
repository.insertFromPreference(
|
||||
indexUrl = source.removeSuffix("/index.min.json").removeSuffix("/index.json") + "/repo.json",
|
||||
name = "Repo #${index + 1}",
|
||||
)
|
||||
} catch (e: SaveExtensionRepoException) {
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e) { "Error Migrating Extension Repo with baseUrl: $source" }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user