Skip to content

Commit 5a6649f

Browse files
committed
fix(Plugins): ignore corrupt plugins
1 parent 2702c3d commit 5a6649f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

app/src/main/kotlin/com/aliucord/manager/ui/screens/plugins/PluginsModel.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,22 @@ class PluginsModel(
193193
?: throw IllegalStateException("Failed to read plugins directory")
194194

195195
val pluginItems = pluginFiles
196-
.map {
197-
PluginItem(
198-
manifest = loadPluginManifest(it),
199-
path = it.absolutePath,
200-
)
196+
.mapNotNull {
197+
try {
198+
PluginItem(
199+
manifest = loadPluginManifest(it),
200+
path = it.absolutePath,
201+
)
202+
} catch (e: Exception) {
203+
Log.e(BuildConfig.TAG, "Failed to load plugin at ${it.absolutePath}", e)
204+
null
205+
}
201206
}
202207
.sortedBy { it.manifest.name }
203208

204209
plugins.value = pluginItems.toUnsafeImmutable()
205210
}
206211

207-
// TODO: don't cause entire page to fail if one plugin is corrupted
208212
private fun loadPluginManifest(pluginFile: File): PluginManifest {
209213
return ZipReader(pluginFile).use {
210214
val manifest = it.openEntry("manifest.json")

0 commit comments

Comments
 (0)