Skip to content

Commit

Permalink
simplify validation
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Feb 28, 2024
1 parent c9da98b commit 94fb22e
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/jni_core/src/jvm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,14 @@ impl JavaVmWrapper {
} else {
tracing::info!("environment variable CONNECTOR_LIBS_PATH is not specified, use default path `./libs` instead");
std::env::current_exe()
.and_then(|p| p.fs_err_canonicalize())
.and_then(|p| p.fs_err_canonicalize()) // resolve symlink of the current executable
.context("unable to get path of the executable")?
.parent()
.expect("not root")
.join("libs")
};

let libs_path = libs_path
.fs_err_canonicalize()
.context("invalid path for connector libs")?;

if !libs_path.exists() {
bail!(
"CONNECTOR_LIBS_PATH \"{}\" does not exist",
libs_path.display()
);
}
if !libs_path.is_dir() {
bail!(
"CONNECTOR_LIBS_PATH \"{}\" is not a directory",
libs_path.display()
);
}

// No need to validate the path now, as it will be further checked when calling `fs::read_dir` later.
Ok(libs_path)
}

Expand Down

0 comments on commit 94fb22e

Please sign in to comment.