Skip to content

Commit 0bfab22

Browse files
committed
feat: add pre-flight checks for mount path and library validation in verification process
1 parent c098e0b commit 0bfab22

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/main.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use solana_sdk::pubkey::Pubkey;
1818
use solana_transaction_status_client_types::UiTransactionEncoding;
1919
use std::{
2020
io::Read,
21-
path::PathBuf,
21+
path::{Path, PathBuf},
2222
process::{Command, Output, Stdio},
2323
sync::{
2424
atomic::{AtomicBool, Ordering},
@@ -1315,6 +1315,8 @@ pub async fn verify_from_repo(
13151315
println!("Build path: {mount_path:?}");
13161316
println!("Verifying program: {library_name}");
13171317

1318+
run_preflight_checks(&mount_path, &library_name)?;
1319+
13181320
check_signal(container_id_opt, temp_dir_opt);
13191321

13201322
let result: Result<(String, String), anyhow::Error> = if !skip_build {
@@ -1667,3 +1669,21 @@ fn find_relative_manifest_path_and_build_path(
16671669
))
16681670
})
16691671
}
1672+
1673+
fn run_preflight_checks(mount_path: &str, library_name: &str) -> anyhow::Result<()> {
1674+
println!("Running pre-flight validation...");
1675+
1676+
// Check that mount path exists
1677+
let mount_path_buf = Path::new(mount_path);
1678+
ensure!(
1679+
mount_path_buf.exists(),
1680+
"Pre-flight check failed: mount path '{}' does not exist.",
1681+
mount_path
1682+
);
1683+
1684+
// Validate that the library can be found using find_relative_manifest_path_and_build_path
1685+
find_relative_manifest_path_and_build_path(mount_path, library_name)?;
1686+
1687+
println!("Pre-flight checks passed ✅");
1688+
Ok(())
1689+
}

0 commit comments

Comments
 (0)