mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests [python]: Survive FSE when accessing pythons from the store.
GitOrigin-RevId: dc13d59d2efd3110b318e6ed9446d33ae15f2d07
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d2912a83a0
commit
dc601f0dca
+10
-3
@@ -5,16 +5,23 @@ import com.intellij.ide.ApplicationInitializedListener
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
|
||||
import com.intellij.python.community.services.systemPython.SystemPythonService
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.nio.file.FileSystemException
|
||||
import kotlin.io.path.pathString
|
||||
|
||||
@TestOnly
|
||||
internal class SystemPythonRootsFixer : ApplicationInitializedListener {
|
||||
override suspend fun execute() {
|
||||
val disposable = ApplicationManager.getApplication()
|
||||
val pythonDirs = SystemPythonService()
|
||||
.findSystemPythons()
|
||||
.map { it.pythonBinary.toRealPath().parent.pathString }
|
||||
.map {
|
||||
try {
|
||||
// It might throw FSE on Windows for pythons installed from store, see WinAppxTools
|
||||
it.pythonBinary.toRealPath()
|
||||
}
|
||||
catch (_: FileSystemException) {
|
||||
it.pythonBinary
|
||||
}.parent.pathString
|
||||
}
|
||||
.toTypedArray()
|
||||
VfsRootAccess.allowRootAccess(disposable, *pythonDirs)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user