Fixed automatic updates

This commit is contained in:
Blatzar 2022-08-17 23:59:21 +02:00
parent 3f134dc0b2
commit 4832421bd2

View file

@ -80,10 +80,11 @@ object PluginManager {
lock.withLock { lock.withLock {
if (data.isOnline) { if (data.isOnline) {
val plugins = getPluginsOnline() val plugins = getPluginsOnline()
setKey(PLUGINS_KEY, plugins + data) val newPlugins = plugins.filter { it.filePath != data.filePath } + data
setKey(PLUGINS_KEY, newPlugins)
} else { } else {
val plugins = getPluginsLocal() val plugins = getPluginsLocal()
setKey(PLUGINS_KEY_LOCAL, plugins + data) setKey(PLUGINS_KEY_LOCAL, plugins.filter { it.filePath != data.filePath } + data)
} }
} }
} }
@ -155,7 +156,7 @@ object PluginManager {
val onlineData: Pair<String, SitePlugin>, val onlineData: Pair<String, SitePlugin>,
) { ) {
val isOutdated = val isOutdated =
onlineData.second.apiVersion != savedData.version || onlineData.second.version == PLUGIN_VERSION_ALWAYS_UPDATE onlineData.second.version != savedData.version || onlineData.second.version == PLUGIN_VERSION_ALWAYS_UPDATE
val isDisabled = onlineData.second.status == PROVIDER_STATUS_DOWN val isDisabled = onlineData.second.status == PROVIDER_STATUS_DOWN
} }
@ -267,8 +268,12 @@ object PluginManager {
} }
} }
val name: String = manifest.name ?: "NO NAME" val name: String = manifest.name ?: "NO NAME".also {
val version: Int = manifest.version ?: PLUGIN_VERSION_NOT_SET Log.d(TAG, "No manifest name for ${data.internalName}")
}
val version: Int = manifest.version ?: PLUGIN_VERSION_NOT_SET.also {
Log.d(TAG, "No manifest version for ${data.internalName}")
}
val pluginClass: Class<*> = val pluginClass: Class<*> =
loader.loadClass(manifest.pluginClassName) as Class<out Plugin?> loader.loadClass(manifest.pluginClassName) as Class<out Plugin?>
val pluginInstance: Plugin = val pluginInstance: Plugin =