Skip to content

Commit

Permalink
remove migration path
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Nov 15, 2023
1 parent 320eb16 commit 7a9d5be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
android:versionCode="444"
android:versionCode="445"
android:versionName="1.6.1">

<uses-feature android:name="android.hardware.type.pc" android:required="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import java.io.File
import java.io.FileReader
import java.io.FileWriter
import java.lang.ref.WeakReference
import javax.inject.Singleton
import kotlin.coroutines.coroutineContext
import kotlin.math.max

Expand Down Expand Up @@ -87,9 +86,7 @@ class ResourceManager {

private fun installedResources(): List<ResourceItem> {
val items = arrayListOf<ResourceItem>()
// Scan script directory first because add-on directory may need migration
val scriptDirPath = scriptDirectory
val trackedIds = hashSetOf<String>()
if (scriptDirPath != null) {
val parentDir = File(scriptDirPath)
if (parentDir.exists() && parentDir.isDirectory) {
Expand All @@ -107,7 +104,6 @@ class ResourceManager {
val item = gson.fromJson(it, ResourceItem::class.java)
if (item.id == folder.name && item.type == "script") {
items.add(item)
trackedIds.add(item.id)
}
}
} catch (ignored: Throwable) {}
Expand All @@ -131,17 +127,8 @@ class ResourceManager {
reader.use {
val gson = GsonBuilder().create()
val item = gson.fromJson(it, ResourceItem::class.java)
if (item.id == folder.name && !trackedIds.contains(item.id)) {
if (item.type == "script") {
// Perform migration by moving folder to scripts folder
try {
val newFolder = File(scriptDirPath, item.id)
folder.renameTo(newFolder)
items.add(item)
} catch (ignored: Throwable) {}
} else {
items.add(item)
}
if (item.id == folder.name && item.type != "script") {
items.add(item)
}
}
} catch (ignored: Throwable) {}
Expand Down

0 comments on commit 7a9d5be

Please sign in to comment.