[eel] EelTargetEnvironmentRequest: fix volumes

GitOrigin-RevId: 19ebbeb07928882715c59170a591d7aae4a2d7b7
This commit is contained in:
Andrii Zinchenko
2024-12-11 12:44:49 +00:00
committed by intellij-monorepo-bot
parent 5cee86bcf8
commit 4d8d636d72
@@ -28,12 +28,14 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.annotations.ApiStatus.Internal
import java.net.InetSocketAddress
import java.net.Socket
import java.nio.file.Path
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import javax.swing.Icon
import kotlin.io.path.pathString
private fun EelPlatform.toTargetPlatform(): TargetPlatform = when (this) {
is EelPlatform.Posix -> TargetPlatform(Platform.UNIX)
@@ -104,7 +106,8 @@ class EelTargetEnvironmentRequest(override val configuration: Configuration) : B
override var shouldCopyVolumes: Boolean = false
}
private class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) : TargetEnvironment(request) {
@Internal
class EelTargetEnvironment(override val request: EelTargetEnvironmentRequest) : TargetEnvironment(request) {
private val myUploadVolumes: MutableMap<UploadRoot, UploadableVolume> = HashMap()
private val myDownloadVolumes: MutableMap<DownloadRoot, DownloadableVolume> = HashMap()
private val myTargetPortBindings: MutableMap<TargetPortBinding, ResolvedPortBinding> = HashMap()
@@ -186,7 +189,7 @@ private class EelTargetEnvironment(override val request: EelTargetEnvironmentReq
override val targetRoot: String,
) : UploadableVolume, DownloadableVolume {
private fun targetRootPath(): Path {
return eel.mapper.toNioPath(eel.fs.getPath(targetRoot))
return eel.fs.toNioFs().getPath(eel.fs.getPath(targetRoot).toString())
}
override fun upload(relativePath: String, targetProgressIndicator: TargetProgressIndicator) {
@@ -194,6 +197,7 @@ private class EelTargetEnvironment(override val request: EelTargetEnvironmentReq
val to = targetRootPath().resolve(relativePath).normalize()
if (from == to) return
// TODO: generalize com.intellij.execution.wsl.ijent.nio.IjentWslNioFileSystemProvider.copy
// TODO: For Docker it might be problematic to copy the owner attribute
EelPathUtils.walkingTransfer(from, to, removeSource = false, copyAttributes = true)
}
@@ -202,11 +206,13 @@ private class EelTargetEnvironment(override val request: EelTargetEnvironmentReq
val to = localRoot.resolve(relativePath).normalize()
if (from == to) return
// TODO: generalize com.intellij.execution.wsl.ijent.nio.IjentWslNioFileSystemProvider.copy
// TODO: For Docker it might be problematic to copy the owner attribute
EelPathUtils.walkingTransfer(from, to, removeSource = false, copyAttributes = true)
}
override fun resolveTargetPath(relativePath: String): String {
return eel.mapper.getOriginalPath(targetRootPath().resolve(relativePath))!!.toString()
val from = targetRootPath().resolve(relativePath)
return eel.mapper.getOriginalPath(from)?.toString() ?: from.pathString
}
companion object {