Skip to content

Commit 6b73d28

Browse files
committed
support plugin downgrade in ui versioning
1 parent 99141bc commit 6b73d28

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ide-common/src/main/kotlin/org/digma/intellij/plugin/updates/ui/UIVersioningService.kt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,31 @@ class UIVersioningService(val cs: CoroutineScope) : DisposableAdaptor {
146146

147147
try {
148148

149-
//update this property so it has a value on the first installation of the ui versioning feature
149+
//update this property so it has a value on the first installation of the ui versioning feature.
150+
//if it doesn't have a value its means that this is the first update to a version that includes the feature,
151+
// or it's a new installation. in both cases it's ok to set the current version to the bundled version. from now on
152+
// current version will always be updated to the used ui version.
150153
if (PersistenceService.getInstance().getCurrentUiVersion() == null) {
151154
setCurrentUiVersion(bundledUiVersion)
152155
}
153156

154-
//first check if there was a plugin downgrade since the last time the current ui version was updated if yes
155-
// switch to the bundled UI
157+
/*
158+
The following code is support for plugin downgrade.
159+
but we don't detect plugin downgrade we eep track of the plugin version that installed the current ui.
160+
this service keeps track of the plugin version every time setCurrentUiVersion() is called.
161+
on startup , this code will check if the current plugin version is older than the plugin version that installed
162+
the current ui version, this definitely means that there was a plugin downgrade and we need to revert to the bundled ui.
163+
the ui will not be reverted if it was installed by the current plugin version. it may be a downgrade of the plugin ,we don't know.
164+
but if this plugin version installed the current ui it will not be downgraded.
165+
for example
166+
plugin version 5 bundled with ui version 1
167+
then upgraded to ui 2
168+
then upgraded to ui 3
169+
upgrade plugin to version 6 that bundles ui 3
170+
no change - ui is already 3
171+
downgrade plugin to version 5
172+
ui will not be reverted because it was installed by plugin version 5
173+
*/
156174
val needToUnpackAfterPluginDowngrade = PersistenceService.getInstance().getLastUiUpdatePluginVersion()?.let { lastUiUpdatePluginVersion ->
157175
val currentPluginVersion = SemanticVersionUtil.getPluginVersionWithoutBuildNumberAndPreRelease("unknown")
158176
ComparableVersion(currentPluginVersion).olderThan(ComparableVersion(lastUiUpdatePluginVersion))

0 commit comments

Comments
 (0)