Skip to content

Commit 7bb9a67

Browse files
committed
refactor: resolve IDEs concurrently
- installed IDEs vs the list from jetbrains.com is now resolved concurrently
1 parent 1f9ea1f commit 7bb9a67

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/kotlin/com/coder/gateway/views/steps/CoderLocateRemoteProjectStepView.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.jetbrains.gateway.ssh.IdeWithStatus
4040
import com.jetbrains.gateway.ssh.IntelliJPlatformProduct
4141
import kotlinx.coroutines.CoroutineScope
4242
import kotlinx.coroutines.Dispatchers
43+
import kotlinx.coroutines.async
4344
import kotlinx.coroutines.cancel
4445
import kotlinx.coroutines.launch
4546
import kotlinx.coroutines.withContext
@@ -146,16 +147,18 @@ class CoderLocateRemoteProjectStepView(private val disableNextAction: () -> Unit
146147
}
147148
} else {
148149
logger.info("Resolved OS and Arch for ${selectedWorkspace.name} is: $workspaceOS")
149-
val installedIdes = withContext(Dispatchers.IO) {
150+
val installedIdesJob = async(Dispatchers.IO) {
150151
hostAccessor.getInstalledIDEs().map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.ALREADY_INSTALLED, null, ide.pathToIde, ide.presentableVersion, ide.remoteDevType) }
151152
}
152-
val idesWithStatus = withContext(Dispatchers.IO) {
153+
val idesWithStatusJob = async(Dispatchers.IO) {
153154
IntelliJPlatformProduct.values()
154155
.filter { it.showInGateway }
155156
.flatMap { CachingProductsJsonWrapper.getInstance().getAvailableIdes(it, workspaceOS) }
156157
.map { ide -> IdeWithStatus(ide.product, ide.buildNumber, IdeStatus.DOWNLOAD, ide.download, null, ide.presentableVersion, ide.remoteDevType) }
157158
}
158159

160+
val installedIdes = installedIdesJob.await()
161+
val idesWithStatus = idesWithStatusJob.await()
159162
if (installedIdes.isEmpty()) {
160163
logger.info("No IDE is installed in workspace ${selectedWorkspace.name}")
161164
} else {

0 commit comments

Comments
 (0)