mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-05 00:28:56 +01:00
Migrate to realm for metadata
This commit is contained in:
@@ -10,11 +10,14 @@ import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.updater.UpdateCheckerJob
|
||||
import eu.kanade.tachiyomi.util.LocaleHelper
|
||||
import io.paperdb.Paper
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.InjektScope
|
||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
||||
import java.io.File
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
open class App : Application() {
|
||||
|
||||
@@ -26,7 +29,7 @@ open class App : Application() {
|
||||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
|
||||
|
||||
setupJobManager()
|
||||
Paper.init(this) //Setup metadata DB (EH)
|
||||
setupRealm() //Setup metadata DB (EH)
|
||||
Reprint.initialize(this) //Setup fingerprint (EH)
|
||||
|
||||
LocaleHelper.updateConfiguration(this, resources.configuration)
|
||||
@@ -55,4 +58,25 @@ open class App : Application() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupRealm() {
|
||||
Realm.init(this)
|
||||
val config = RealmConfiguration.Builder()
|
||||
.name("gallery-metadata.realm")
|
||||
.schemaVersion(1)
|
||||
.build()
|
||||
Realm.setDefaultConfiguration(config)
|
||||
|
||||
//Delete old paper db files
|
||||
listOf(
|
||||
File(filesDir, "gallery-ex"),
|
||||
File(filesDir, "gallery-perveden"),
|
||||
File(filesDir, "gallery-nhentai")
|
||||
).forEach {
|
||||
if(it.exists()) {
|
||||
thread {
|
||||
it.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user