-
-
Notifications
You must be signed in to change notification settings - Fork 94
Description
I was thinking about how we could roll the functionality of the https://github.com/processing/processing-vscode-extension/tree/main/install-locator into the PDE and then I realised that the function below is somewhat brittle. If for any reason a change happens in the future that allows this version check to be skipped, this process will turn into an infinite loop / fork bomb.
processing4/app/src/processing/app/Processing.kt
Lines 47 to 55 in 275d789
if(version){ | |
println("processing-${Base.getVersionName()}-${Base.getRevision()}") | |
return | |
} | |
thread { | |
// Update the install locations in preferences | |
updateInstallLocations() | |
} |
When launching Processing the updateInstallLocation
function deserialises the preference string of all installed Processing versions and then per version check if that version is still installed at that location by called its CLI with --version
. The if statement is the only thing preventing updateInstallLocation
in the child process. All in all I would like to come up with a setup that makes sure that we call the child processes a little less.
processing4/app/src/processing/app/Processing.kt
Lines 102 to 129 in 275d789
fun updateInstallLocations(){ | |
val preferences = Preferences.userRoot().node("org/processing/app") | |
val installLocations = preferences.get("installLocations", "") | |
.split(",") | |
.dropLastWhile { it.isEmpty() } | |
.filter { install -> | |
try{ | |
val (path, version) = install.split("^") | |
val file = File(path) | |
if(!file.exists() || file.isDirectory){ | |
return@filter false | |
} | |
// call the path to check if it is a valid install location | |
val process = ProcessBuilder(path, "--version") | |
.redirectErrorStream(true) | |
.start() | |
val exitCode = process.waitFor() | |
if(exitCode != 0){ | |
return@filter false | |
} | |
val output = process.inputStream.bufferedReader().readText() | |
return@filter output.contains(version) | |
} catch (e: Exception){ | |
false | |
} | |
} | |
.toMutableList() | |
val command = ProcessHandle.current().info().command() |
This is not super high priority, just figured I'd flag it.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status