Skip to content

Commit

Permalink
GHI-167: add config storage name replacement (#168)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Lisenkov <[email protected]>
  • Loading branch information
dnlsv authored Jan 18, 2024
1 parent b5049cc commit 93075bc
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,33 @@ class ZoweOldConfigConvertPreloadingActivity : PreloadingActivity() {
}
}

/**
* Replace config storage name with old one if new config file doesn't exist
*/
private fun replaceConfigStorageName() {
val oldConfigStorageName = "org.zowe.explorer.config.OldConfigService"
val newConfigStorageName = "org.zowe.explorer.config.ConfigService"
val oldConfigName = "zowe_explorer_intellij_config.xml"
val newConfigName = "zowe_explorer_intellij_config_v2.xml"
val configPathDir = Paths.get(PathManager.getConfigPath(), PathManager.OPTIONS_DIRECTORY)
val oldConfigFile = File(Paths.get(configPathDir.pathString, oldConfigName).pathString)
val newConfigFile = File(Paths.get(configPathDir.pathString, newConfigName).pathString)
if (oldConfigFile.exists() && !newConfigFile.exists()) {
val charset = Charsets.UTF_8
runCatching {
val newContent =
oldConfigFile
.readText(charset)
.replace(newConfigStorageName.toRegex(), oldConfigStorageName)
Files.write(oldConfigFile.toPath(), newContent.toByteArray(charset))
service<IComponentStore>().reloadState(OldConfigServiceImpl::class.java)
}
}
}

override fun preload(indicator: ProgressIndicator) {
convertOldVersionConfig()
replaceConfigStorageName()
}

}

0 comments on commit 93075bc

Please sign in to comment.