@@ -20,6 +20,7 @@ import com.intellij.platform.eel.EelApi
2020import com.intellij.platform.eel.EelDescriptor
2121import com.intellij.platform.eel.EelExecApi
2222import com.intellij.platform.eel.EelExecApi.EnvironmentVariablesException
23+ import com.intellij.platform.eel.EelMachine
2324import com.intellij.platform.eel.EelOsFamily
2425import com.intellij.platform.eel.EelPathBoundDescriptor
2526import com.intellij.platform.eel.EelTunnelsApi
@@ -33,9 +34,10 @@ import com.intellij.platform.eel.path.EelPath
3334import com.intellij.platform.eel.provider.asEelPath
3435import com.intellij.platform.eel.provider.asNioPath
3536import com.intellij.platform.eel.provider.getEelDescriptor
36- import com.intellij.platform.eel.provider.toEelApi
37- import com.intellij.platform.eel.provider.utils.EelPathTransfer
37+ import com.intellij.platform.eel.provider.getResolvedEelMachine
38+ import com.intellij.platform.eel.provider.resolveEelMachine
3839import com.intellij.platform.eel.provider.utils.EelFileTransferAttributesStrategy
40+ import com.intellij.platform.eel.provider.utils.EelPathTransfer
3941import com.intellij.platform.eel.provider.utils.asEelChannel
4042import com.intellij.platform.eel.provider.utils.consumeAsEelChannel
4143import com.intellij.platform.eel.provider.utils.copy
@@ -145,7 +147,9 @@ class EelTargetEnvironmentRequest(
145147 override val asTargetConfig: TargetEnvironmentConfiguration = this
146148
147149 override fun getTargetPathIfLocalPathIsOnTarget (probablyPathOnTarget : Path ): FullPathOnTarget ? {
148- return probablyPathOnTarget.asEelPath().takeIf { it.descriptor == descriptor }?.toString()
150+ val eelPath = probablyPathOnTarget.asEelPath()
151+ val targetMachine = descriptor.getResolvedEelMachine()
152+ return eelPath.takeIf { it.descriptor == descriptor || targetMachine?.ownsDescriptor(it.descriptor) == true }?.toString()
149153 }
150154
151155 override fun getState (): PersistentState {
@@ -188,9 +192,13 @@ class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) :
188192 private val myTargetPortBindings: MutableMap <TargetPortBinding , ResolvedPortBinding > = HashMap ()
189193 private val myLocalPortBindings: MutableMap <LocalPortBinding , ResolvedPortBinding > = ConcurrentHashMap ()
190194 private val acceptors = ConcurrentLinkedQueue <EelTunnelsApi .ConnectionAcceptor >()
195+ private val descriptor = request.configuration.descriptor
196+ private val eelMachine = runBlockingMaybeCancellable {
197+ descriptor.resolveEelMachine()
198+ }
191199
192200 private val eel = runBlockingMaybeCancellable {
193- request.configuration.descriptor. toEelApi()
201+ eelMachine. toEelApi(descriptor )
194202 }
195203
196204 private val forwardingScope by lazy { service<EelTargetScope >().scope.childScope(" Eel target forwarding scope: ${request.configuration.descriptor} " ) }
@@ -206,11 +214,11 @@ class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) :
206214
207215 init {
208216 request.uploadVolumes.forEach { uploadRoot ->
209- myUploadVolumes[uploadRoot] = EelVolume .createFor(eel, uploadRoot, request.uploadVolumeFilters[uploadRoot])
217+ myUploadVolumes[uploadRoot] = EelVolume .createFor(eel, eelMachine, uploadRoot, request.uploadVolumeFilters[uploadRoot])
210218 }
211219
212220 request.downloadVolumes.forEach { downloadRoot ->
213- myDownloadVolumes[downloadRoot] = EelVolume .createFor(eel, downloadRoot)
221+ myDownloadVolumes[downloadRoot] = EelVolume .createFor(eel, eelMachine, downloadRoot)
214222 }
215223
216224 request.targetPortBindings.forEach { targetPortBinding ->
@@ -317,6 +325,7 @@ class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) :
317325 companion object {
318326 private fun createFor (
319327 eel : EelApi ,
328+ eelMachine : EelMachine ,
320329 localPathGetter : () -> Path ,
321330 targetPathGetter : () -> TargetPath ,
322331 filter : ((Path ) -> Boolean )? ,
@@ -326,7 +335,7 @@ class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) :
326335 val remoteRoot = when (val targetRootPath = targetPathGetter()) {
327336 is TargetPath .Temporary -> {
328337 val localEelPath = localRootPath.asEelPath()
329- if (localEelPath.descriptor == eel.descriptor) {
338+ if (localEelPath.descriptor == eel.descriptor || eelMachine.ownsDescriptor(localEelPath.descriptor) ) {
330339 localEelPath.toString()
331340 }
332341 else {
@@ -347,16 +356,16 @@ class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) :
347356 return EelVolume (eel, filter, localRootPath, remoteRoot)
348357 }
349358
350- fun createFor (eel : EelApi , uploadRoot : UploadRoot , filter : ((Path ) -> Boolean )? ): EelVolume {
351- return createFor(eel, { uploadRoot.localRootPath }, { uploadRoot.targetRootPath }, filter)
359+ fun createFor (eel : EelApi , eelMachine : EelMachine , uploadRoot : UploadRoot , filter : ((Path ) -> Boolean )? ): EelVolume {
360+ return createFor(eel, eelMachine, { uploadRoot.localRootPath }, { uploadRoot.targetRootPath }, filter)
352361 }
353362
354- fun createFor (eel : EelApi , downloadRoot : DownloadRoot ): EelVolume {
363+ fun createFor (eel : EelApi , eelMachine : EelMachine , downloadRoot : DownloadRoot ): EelVolume {
355364 val localRootPath =
356365 downloadRoot.localRootPath
357366 ? : FileUtil .createTempDirectory(" intellij-eel-target." , " " ).toPath()
358367
359- return createFor(eel, { localRootPath }, { downloadRoot.targetRootPath }, null )
368+ return createFor(eel, eelMachine, { localRootPath }, { downloadRoot.targetRootPath }, null )
360369 }
361370 }
362371 }
0 commit comments