You've already forked AstralRinth
forked from didirus/AstralRinth
Fix failure when "Test"ing a Java installation (#3935)
* Fix failure when "Test"ing a Java installation * Fix lint
This commit is contained in:
@@ -108,7 +108,6 @@ async function testJava() {
|
|||||||
testingJava.value = true
|
testingJava.value = true
|
||||||
testingJavaSuccess.value = await test_jre(
|
testingJavaSuccess.value = await test_jre(
|
||||||
props.modelValue ? props.modelValue.path : '',
|
props.modelValue ? props.modelValue.path : '',
|
||||||
1,
|
|
||||||
props.version,
|
props.version,
|
||||||
)
|
)
|
||||||
testingJava.value = false
|
testingJava.value = false
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ export async function get_jre(path) {
|
|||||||
|
|
||||||
// Tests JRE version by running 'java -version' on it.
|
// Tests JRE version by running 'java -version' on it.
|
||||||
// Returns true if the version is valid, and matches given (after extraction)
|
// Returns true if the version is valid, and matches given (after extraction)
|
||||||
export async function test_jre(path, majorVersion, minorVersion) {
|
export async function test_jre(path, majorVersion) {
|
||||||
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion, minorVersion })
|
return await invoke('plugin:jre|jre_test_jre', { path, majorVersion })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically installs specified java version
|
// Automatically installs specified java version
|
||||||
|
|||||||
@@ -166,10 +166,18 @@ pub async fn test_jre(
|
|||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
major_version: u32,
|
major_version: u32,
|
||||||
) -> crate::Result<bool> {
|
) -> crate::Result<bool> {
|
||||||
let Ok(jre) = jre::check_java_at_filepath(&path).await else {
|
let jre = match jre::check_java_at_filepath(&path).await {
|
||||||
return Ok(false);
|
Ok(jre) => jre,
|
||||||
|
Err(e) => {
|
||||||
|
tracing::warn!("Invalid Java at {}: {e}", path.display());
|
||||||
|
return Ok(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let version = extract_java_version(&jre.version)?;
|
let version = extract_java_version(&jre.version)?;
|
||||||
|
tracing::info!(
|
||||||
|
"Expected Java version {major_version}, and found {version} at {}",
|
||||||
|
path.display()
|
||||||
|
);
|
||||||
Ok(version == major_version)
|
Ok(version == major_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user