@@ -83,29 +83,7 @@ class WorkspaceProjectIDE(
83
83
true
84
84
)
85
85
86
- // Ensure the IDE exists. If not, download it if we have a download
87
- // URL. We do this ourselves instead of just giving JetBrains the
88
- // download source or path and letting them handle it:
89
- // 1. To get the actual directory into which the IDE is extracted (the
90
- // postDeployCallback does not give us this information). We want
91
- // this directory to run a setup script inside it.
92
- // 2. To provide a better error message when the IDE is gone (JetBrains
93
- // by default will just hang trying to connect to it).
94
- // 3. So if the IDE was deleted, we can download it again assuming we
95
- // stored the original download URL.
96
- val path: String
97
- if (idePathOnHost.isNullOrBlank()) {
98
- logger.info(" No install found for $ideName on $hostname " )
99
- path = this .doDeploy(accessor, indicator, timeout)
100
- } else {
101
- indicator.text = " Verifying remote IDE exists..."
102
- logger.info(" Verifying $ideName exists at $idePathOnHost on $hostname " )
103
- val validatedPath = validateIDEInstallPath(idePathOnHost, accessor).pathOrNull
104
- path = if (validatedPath != null ) {
105
- logger.info(" $ideName already exists at ${validatedPath.toRawString()} on $hostname " )
106
- validatedPath.toRawString()
107
- } else this .doDeploy(accessor, indicator, timeout)
108
- }
86
+ val path = this .doDeploy(accessor, indicator, timeout)
109
87
idePathOnHost = path
110
88
111
89
if (setupCommand.isNotBlank()) {
@@ -148,13 +126,38 @@ class WorkspaceProjectIDE(
148
126
}
149
127
150
128
/* *
151
- * Deploy the IDE and return the path to its location on disk.
129
+ * Deploy the IDE if necessary and return the path to its location on disk.
152
130
*/
153
131
private suspend fun doDeploy (accessor : HighLevelHostAccessor , indicator : ProgressIndicator , timeout : Duration ): String {
132
+ // The backend might already exist at the provided path.
133
+ if (! idePathOnHost.isNullOrBlank()) {
134
+ indicator.text = " Verifying $ideName installation..."
135
+ logger.info(" Verifying $ideName exists at $idePathOnHost on $hostname " )
136
+ val validatedPath = validateIDEInstallPath(idePathOnHost, accessor).pathOrNull
137
+ if (validatedPath != null ) {
138
+ logger.info(" $ideName exists at ${validatedPath.toRawString()} on $hostname " )
139
+ return validatedPath.toRawString()
140
+ }
141
+ }
142
+
143
+ // The backend might already be installed somewhere on the system.
144
+ indicator.text = " Searching for $ideName installation..."
145
+ logger.info(" Searching for $ideName on $hostname " )
146
+ val installed = accessor.getInstalledIDEs().find {
147
+ it.product == ideProductCode && it.buildNumber == ideBuildNumber }
148
+ if (installed != null ) {
149
+ logger.info(" $ideName found at ${installed.pathToIde} on $hostname " )
150
+ return installed.pathToIde
151
+ }
152
+
153
+ // Otherwise we have to download it.
154
154
if (downloadSource.isNullOrBlank()) {
155
155
throw Exception (" The IDE could not be found on the remote and no download source was provided" )
156
156
}
157
157
158
+ // TODO: Should we download to idePathOnHost if set? That would require
159
+ // symlinking instead of creating the sentinel file if the path is
160
+ // outside the default dist directory.
158
161
val distDir = accessor.getDefaultDistDir()
159
162
160
163
// HighLevelHostAccessor.downloadFile does NOT create the directory.
0 commit comments