Disable UpdatingEditionProvider when running Enso CLI (#10408)

This commit is contained in:
Jaroslav Tulach 2024-07-03 07:33:01 +02:00 committed by GitHub
parent 48fb999eb3
commit 5e3a5b7751
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 38 additions and 23 deletions

View File

@ -158,7 +158,11 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: Level) {
val distributionManager = new DistributionManager(environment)
val editionProvider =
EditionManager.makeEditionProvider(distributionManager, Some(languageHome))
EditionManager.makeEditionProvider(
distributionManager,
Some(languageHome),
false
)
val editionResolver = EditionResolver(editionProvider)
val editionReferenceResolver = new EditionReferenceResolver(
contentRoot.file,

View File

@ -347,7 +347,8 @@ abstract class BaseServerTest
val editionProvider =
EditionManager.makeEditionProvider(
distributionManager,
Some(languageHome)
Some(languageHome),
true
)
val editionResolver = EditionResolver(editionProvider)
val editionReferenceResolver = new EditionReferenceResolver(

View File

@ -43,7 +43,8 @@ object DependencyPreinstaller {
val editionProvider = EditionManager.makeEditionProvider(
distributionManager,
Some(languageHome)
Some(languageHome),
true
)
val editionResolver = EditionResolver(editionProvider)
val edition = editionResolver

View File

@ -10,7 +10,9 @@ import java.nio.file.Path
import scala.util.Try
/** A helper class for resolving editions. */
class EditionManager private (editionProvider: UpdatingEditionProvider) {
class EditionManager private (
editionProvider: editions.provider.EditionProvider
) {
private val editionResolver = EditionResolver(editionProvider)
private val engineVersionResolver =
editions.EngineVersionResolver(editionProvider)
@ -46,18 +48,26 @@ class EditionManager private (editionProvider: UpdatingEditionProvider) {
object EditionManager {
/** Create an [[EditionProvider]] that can locate editions from the
* distribution and the language home.
* distribution (if updating) and the language home.
*/
def makeEditionProvider(
final def makeEditionProvider(
distributionManager: DistributionManager,
languageHome: Option[LanguageHome]
): UpdatingEditionProvider = {
val config = new GlobalConfigurationManager(distributionManager).getConfig
new UpdatingEditionProvider(
getSearchPaths(distributionManager, languageHome),
distributionManager.paths.cachedEditions,
config.editionProviders
)
languageHome: Option[LanguageHome],
updating: Boolean
): editions.provider.EditionProvider = {
val config = new GlobalConfigurationManager(distributionManager).getConfig
val searchPaths = getSearchPaths(distributionManager, languageHome)
val cachePath = distributionManager.paths.cachedEditions
if (updating) {
new UpdatingEditionProvider(
searchPaths,
cachePath,
config.editionProviders
)
} else {
val actualSearchPaths = (searchPaths ++ List(cachePath)).distinct
new editions.provider.FileSystemEditionProvider(actualSearchPaths)
}
}
/** Get search paths associated with the distribution and language home. */
@ -77,6 +87,6 @@ object EditionManager {
distributionManager: DistributionManager,
languageHome: Option[LanguageHome] = None
): EditionManager = new EditionManager(
makeEditionProvider(distributionManager, languageHome)
makeEditionProvider(distributionManager, languageHome, false)
)
}

View File

@ -38,12 +38,8 @@ class UpdatingEditionProvider(
case Right(value) => Right(value)
}
/** Finds all editions available on the [[searchPaths]]. */
override def findAvailableEditions(): Seq[String] =
provider.findAvailableEditions()
/** Finds all available editions, performing an update if asked to. */
def findAvailableEditions(update: Boolean): Seq[String] = {
override def findAvailableEditions(update: Boolean): Seq[String] = {
if (update) {
updater.updateEditions()
}

View File

@ -15,5 +15,5 @@ trait EditionProvider {
): Either[EditionLoadingError, Editions.Raw.Edition]
/** Finds all editions that are currently available. */
def findAvailableEditions(): Seq[String]
def findAvailableEditions(update: Boolean = false): Seq[String]
}

View File

@ -51,7 +51,9 @@ class FileSystemEditionProvider(searchPaths: List[Path])
}
/** Finds all editions available on the [[searchPaths]]. */
override def findAvailableEditions(): Seq[String] =
override def findAvailableEditions(
ignoreUpdateRequest: Boolean
): Seq[String] =
searchPaths.flatMap(findEditionsAt).distinct
private def findEditionName(path: Path): Option[String] =

View File

@ -54,7 +54,8 @@ class EditionResolverSpec
): Either[EditionLoadingError, Editions.Raw.Edition] =
editions.get(name).toRight(EditionNotFound(name))
override def findAvailableEditions(): Seq[String] = editions.keys.toSeq
override def findAvailableEditions(update: Boolean): Seq[String] =
editions.keys.toSeq
}
val resolver = EditionResolver(FakeEditionProvider)