update: dev version check

This commit is contained in:
Dmitry Bushev 2023-08-23 12:15:53 +03:00
parent 2385f5b357
commit c121d57215
No known key found for this signature in database
GPG Key ID: 87C16090D6910E91
7 changed files with 23 additions and 9 deletions

View File

@ -261,11 +261,13 @@ object ProjectManagementApi {
case class BrokenComponentError(msg: String) extends Error(4021, msg)
case class ProjectManagerUpgradeRequired(minimumRequiredVersion: SemVer)
extends Error(
case class ProjectManagerUpgradeRequired(
currentVersion: SemVer,
minimumRequiredVersion: SemVer
) extends Error(
4022,
s"Project manager $minimumRequiredVersion is required to install the " +
s"requested engine. Please upgrade."
s"requested engine. Current version is $currentVersion. Please upgrade."
) {
/** Additional payload that can be used to get the version string of the

View File

@ -27,8 +27,8 @@ object ProjectServiceFailureMapper {
case CannotRemoveOpenProject => CannotRemoveOpenProjectError
case ProjectOperationTimeout => ServiceError
case LanguageServerFailure(msg) => LanguageServerError(msg)
case ProjectManagerUpgradeRequiredFailure(version) =>
ProjectManagerUpgradeRequired(version)
case ProjectManagerUpgradeRequiredFailure(current, required) =>
ProjectManagerUpgradeRequired(current, required)
case MissingComponentFailure(msg) => MissingComponentError(msg)
case BrokenComponentFailure(msg) => BrokenComponentError(msg)
case ComponentInstallationFailure(msg) => ComponentInstallationError(msg)

View File

@ -84,6 +84,7 @@ object ProjectServiceFailure {
* than what is currently running.
*/
case class ProjectManagerUpgradeRequiredFailure(
currentVersion: SemVer,
minimumRequiredVersion: SemVer
) extends ProjectServiceFailure

View File

@ -29,6 +29,7 @@ object RuntimeVersionManagerErrorRecoverySyntax {
MissingComponentFailure(message)
case upgradeRequired: UpgradeRequiredError =>
ProjectManagerUpgradeRequiredFailure(
upgradeRequired.currentVersion,
upgradeRequired.expectedVersion
)
case UninstallationError(message) =>

View File

@ -25,7 +25,7 @@ object CurrentVersion {
/** Check if the current version is the development one. */
def isDevVersion: Boolean =
currentVersion == defaultDevEnsoVersion
currentVersion.preRelease == defaultDevEnsoVersion.preRelease
/** Override launcher version with the provided one.
*

View File

@ -59,13 +59,15 @@ case class ComponentMissingError(message: String, cause: Throwable = null)
/** Indicates that a requested engine version requires a newer launcher/project
* manager version.
*
* @param currentVersion the current engine version
* @param expectedVersion the minimum version that is required to run the engine
*/
case class UpgradeRequiredError(
currentVersion: SemVer,
expectedVersion: SemVer
) extends ComponentsException(
s"Minimum version required to use this engine is " +
s"$expectedVersion."
s"$expectedVersion. Current version is $currentVersion."
)
/** Indicates uninstallation failure. */

View File

@ -464,7 +464,10 @@ class RuntimeVersionManager(
engineRelease.manifest
)
if (!isCompatible) {
throw UpgradeRequiredError(engineRelease.manifest.minimumRequiredVersion)
throw UpgradeRequiredError(
CurrentVersion.version,
engineRelease.manifest.minimumRequiredVersion
)
}
if (engineRelease.isBroken) {
val continue = userInterface.shouldInstallBrokenEngine(version)
@ -726,7 +729,12 @@ class RuntimeVersionManager(
): Try[Manifest] = {
Manifest.load(path / Manifest.DEFAULT_MANIFEST_NAME).flatMap { manifest =>
if (!isEngineVersionCompatibleWithThisInstaller(manifest)) {
Failure(UpgradeRequiredError(manifest.minimumRequiredVersion))
Failure(
UpgradeRequiredError(
CurrentVersion.version,
manifest.minimumRequiredVersion
)
)
} else Success(manifest)
}
}