migration bug fixed
This commit is contained in:
@@ -38,7 +38,7 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 64
|
||||
versionName "5.1.7"
|
||||
versionName "5.1.7-hotfix1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 64,
|
||||
"versionName": "5.1.7",
|
||||
"versionName": "5.1.7-hotfix1",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -137,5 +137,9 @@ operator fun JsonElement.get(index: Int) =
|
||||
operator fun JsonElement.get(tag: String) =
|
||||
this.jsonObject[tag]
|
||||
|
||||
fun JsonElement.getOrNull(tag: String) = kotlin.runCatching {
|
||||
this.jsonObject.getOrDefault(tag, null)
|
||||
}.getOrNull()
|
||||
|
||||
val JsonElement.content
|
||||
get() = this.jsonPrimitive.contentOrNull
|
||||
@@ -285,11 +285,11 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
|
||||
folder.getChild(".metadata").readText()?.let { Json.parseToJsonElement(it) }
|
||||
}.getOrNull()
|
||||
|
||||
val galleryID = metadata?.get("reader")?.get("galleryInfo")?.get("id")?.content?.toIntOrNull()
|
||||
val galleryID = metadata?.getOrNull("reader")?.getOrNull("galleryInfo")?.getOrNull("id")?.content?.toIntOrNull()
|
||||
?: folder.name.toIntOrNull() ?: return@forEachIndexed
|
||||
|
||||
val galleryBlock: GalleryBlock? = kotlin.runCatching {
|
||||
metadata?.get("galleryBlock")?.let { Json.decodeFromJsonElement<GalleryBlock>(it) }
|
||||
metadata?.getOrNull("galleryBlock")?.let { Json.decodeFromJsonElement<GalleryBlock>(it) }
|
||||
}.getOrNull() ?: kotlin.runCatching {
|
||||
getGalleryBlock(galleryID)
|
||||
}.getOrNull() ?: kotlin.runCatching {
|
||||
@@ -297,14 +297,14 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
|
||||
}.getOrNull()
|
||||
|
||||
val reader: Reader? = kotlin.runCatching {
|
||||
metadata?.get("reader")?.let { Json.decodeFromJsonElement<Reader>(it) }
|
||||
metadata?.getOrNull("reader")?.let { Json.decodeFromJsonElement<Reader>(it) }
|
||||
}.getOrNull() ?: kotlin.runCatching {
|
||||
getReader(galleryID)
|
||||
}.getOrNull() ?: kotlin.runCatching {
|
||||
xyz.quaver.hiyobi.getReader(galleryID)
|
||||
}.getOrNull()
|
||||
|
||||
metadata?.get("thumbnail")?.jsonPrimitive?.contentOrNull?.also { thumbnail ->
|
||||
metadata?.getOrNull("thumbnail")?.jsonPrimitive?.contentOrNull?.also { thumbnail ->
|
||||
val file = folder.getChild(".thumbnail").also {
|
||||
if (it.exists())
|
||||
it.delete()
|
||||
|
||||
Reference in New Issue
Block a user