mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
fix: add context to file-not-found errors (#7665)
This commit is contained in:
@@ -111,7 +111,11 @@ impl CoreManager {
|
||||
|
||||
#[cfg(unix)]
|
||||
let previous_mask = unsafe { tauri_plugin_clash_verge_sysinfo::libc::umask(0o077) };
|
||||
let command = app_handle.shell().sidecar(clash_core.as_str())?.args([
|
||||
let command = app_handle
|
||||
.shell()
|
||||
.sidecar(clash_core.as_str())
|
||||
.map_err(|error| anyhow::anyhow!("failed to build sidecar command for core {clash_core:?}: {error:#}"))?;
|
||||
let command = command.args([
|
||||
"-d",
|
||||
dirs::path_to_str(&config_dir)?,
|
||||
"-f",
|
||||
@@ -128,7 +132,13 @@ impl CoreManager {
|
||||
"LISTEN_NAMEDPIPE_SDDL",
|
||||
crate::core::owner_identity::current_user_pipe_sddl()?,
|
||||
);
|
||||
let (mut rx, child) = command.spawn()?;
|
||||
let (mut rx, child) = command.spawn().map_err(|error| {
|
||||
anyhow::anyhow!(
|
||||
"failed to start sidecar core {clash_core:?} with config {} and data directory {}: {error:#}",
|
||||
config_file.display(),
|
||||
config_dir.display()
|
||||
)
|
||||
})?;
|
||||
#[cfg(target_os = "windows")]
|
||||
let job = {
|
||||
match create_and_assign_sidecar_job(child.pid()) {
|
||||
|
||||
@@ -438,7 +438,13 @@ fn macos_service_tool_path(source: &Path) -> Result<PathBuf> {
|
||||
}
|
||||
|
||||
fn service_core_path(clash_core: &str, bin_ext: &str) -> Result<PathBuf> {
|
||||
let sibling = current_exe()?.with_file_name(format!("{clash_core}{bin_ext}"));
|
||||
let sibling = current_exe()
|
||||
.map_err(|error| {
|
||||
anyhow::anyhow!(
|
||||
"failed to locate the current executable while resolving Service core {clash_core:?}: {error}"
|
||||
)
|
||||
})?
|
||||
.with_file_name(format!("{clash_core}{bin_ext}"));
|
||||
|
||||
#[cfg(all(target_os = "macos", feature = "verge-dev"))]
|
||||
{
|
||||
@@ -898,7 +904,10 @@ pub(super) async fn start_with_existing_service(config_file: &Path) -> Result<()
|
||||
let err_msg = response.message;
|
||||
logging!(error, Type::Service, "启动核心失败: {}", err_msg);
|
||||
start_owner_monitor();
|
||||
bail!(err_msg);
|
||||
bail!(
|
||||
"failed to start Service core at {}: {err_msg}",
|
||||
request.runtime.core_path
|
||||
);
|
||||
}
|
||||
|
||||
let result = response.data.context("Clash Verge Service 未返回会话信息")?;
|
||||
|
||||
@@ -348,12 +348,16 @@ impl CoreConfigValidator {
|
||||
logging!(info, Type::Validate, "验证目录: {}", app_dir_str);
|
||||
|
||||
// 使用子进程运行clash验证配置
|
||||
let command =
|
||||
app_handle
|
||||
.shell()
|
||||
.sidecar(clash_core.as_str())?
|
||||
.args(["-t", "-d", app_dir_str, "-f", config_path]);
|
||||
let output = command.output().await?;
|
||||
let command = app_handle.shell().sidecar(clash_core.as_str()).map_err(|error| {
|
||||
anyhow::anyhow!("failed to build validation command for core {clash_core:?}: {error:#}")
|
||||
})?;
|
||||
let command = command.args(["-t", "-d", app_dir_str, "-f", config_path]);
|
||||
let output = command.output().await.map_err(|error| {
|
||||
anyhow::anyhow!(
|
||||
"failed to run validation core {clash_core:?} for config {config_path:?} in data directory {}: {error:#}",
|
||||
app_dir.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
let status = &output.status;
|
||||
let stderr = &output.stderr;
|
||||
|
||||
@@ -256,7 +256,12 @@ pub fn snapshot_path(original_path: &Path) -> Result<PathBuf> {
|
||||
.ok_or_else(|| anyhow!("Invalid log path"))?
|
||||
.join("temp");
|
||||
|
||||
std::fs::create_dir_all(&temp_dir)?;
|
||||
std::fs::create_dir_all(&temp_dir).map_err(|error| {
|
||||
anyhow!(
|
||||
"failed to create log snapshot directory {}: {error}",
|
||||
temp_dir.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
let temp_path = temp_dir.join(format!(
|
||||
"{}_{}.log",
|
||||
@@ -264,7 +269,13 @@ pub fn snapshot_path(original_path: &Path) -> Result<PathBuf> {
|
||||
chrono::Local::now().format("%Y-%m-%d_%H-%M-%S")
|
||||
));
|
||||
|
||||
std::fs::copy(original_path, &temp_path)?;
|
||||
std::fs::copy(original_path, &temp_path).map_err(|error| {
|
||||
anyhow!(
|
||||
"failed to copy log snapshot from {} to {}: {error}",
|
||||
original_path.display(),
|
||||
temp_path.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(temp_path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user