1
0

Fix failure when "Test"ing a Java installation (#3935)

* Fix failure when "Test"ing a Java installation

* Fix lint
This commit is contained in:
Josiah Glosson
2025-07-07 14:11:36 -05:00
committed by GitHub
parent c47bcf665d
commit 088cb54317
3 changed files with 12 additions and 5 deletions

View File

@@ -108,7 +108,6 @@ async function testJava() {
testingJava.value = true
testingJavaSuccess.value = await test_jre(
props.modelValue ? props.modelValue.path : '',
1,
props.version,
)
testingJava.value = false

View File

@@ -36,8 +36,8 @@ export async function get_jre(path) {
// Tests JRE version by running 'java -version' on it.
// Returns true if the version is valid, and matches given (after extraction)
export async function test_jre(path, majorVersion, minorVersion) {
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion, minorVersion })
export async function test_jre(path, majorVersion) {
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion })
}
// Automatically installs specified java version

View File

@@ -166,10 +166,18 @@ pub async fn test_jre(
path: PathBuf,
major_version: u32,
) -> crate::Result<bool> {
let Ok(jre) = jre::check_java_at_filepath(&path).await else {
return Ok(false);
let jre = match jre::check_java_at_filepath(&path).await {
Ok(jre) => jre,
Err(e) => {
tracing::warn!("Invalid Java at {}: {e}", path.display());
return Ok(false);
}
};
let version = extract_java_version(&jre.version)?;
tracing::info!(
"Expected Java version {major_version}, and found {version} at {}",
path.display()
);
Ok(version == major_version)
}