fix: Fix remaining E0716 borrow errors in path refactoring
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
Some checks failed
BotServer CI/CD / build (push) Has been cancelled
- server.rs: Use PathBuf for cert_dir - auth_routes.rs: Use PathBuf for pat_path - qrcode.rs: Bind get_work_path() to local var before unwrap_or - import_export.rs: Bind get_work_path() to local var in both functions (2 occurrences)
This commit is contained in:
parent
552d58376f
commit
be6f0306cc
4 changed files with 9 additions and 34 deletions
|
|
@ -234,41 +234,13 @@ fn resolve_file_path(
|
|||
return Ok(file_path.to_string());
|
||||
}
|
||||
|
||||
let work = get_work_path();
|
||||
let work = get_work_path();
|
||||
let data_dir = state
|
||||
.config
|
||||
.as_ref()
|
||||
.map(|c| c.data_dir.as_str())
|
||||
.unwrap_or(&get_work_path());
|
||||
let base_path = format!("{}/bots/{}/gbdrive", data_dir, user.bot_id);
|
||||
|
||||
let full_path = format!("{}/{}", base_path, file_path);
|
||||
|
||||
if Path::new(&full_path).exists() {
|
||||
Ok(full_path)
|
||||
} else {
|
||||
let alt_path = format!("{}/bots/{}/{}", data_dir, user.bot_id, file_path);
|
||||
if Path::new(&alt_path).exists() {
|
||||
Ok(alt_path)
|
||||
} else {
|
||||
Err(format!("File not found: {}", file_path).into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_export_path(
|
||||
state: &AppState,
|
||||
user: &UserSession,
|
||||
file_path: &str,
|
||||
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
|
||||
if Path::new(file_path).is_absolute() {
|
||||
return Ok(file_path.to_string());
|
||||
}
|
||||
|
||||
let data_dir = state
|
||||
.config
|
||||
.as_ref()
|
||||
.map(|c| c.data_dir.as_str())
|
||||
.unwrap_or(&get_work_path());
|
||||
.unwrap_or(&work);
|
||||
let base_path = format!("{}/bots/{}/gbdrive", data_dir, user.bot_id);
|
||||
|
||||
std::fs::create_dir_all(&base_path)?;
|
||||
|
|
|
|||
|
|
@ -248,11 +248,12 @@ fn execute_qr_code_generation(
|
|||
}
|
||||
}
|
||||
|
||||
let work_path = crate::core::shared::utils::get_work_path();
|
||||
let data_dir = state
|
||||
.config
|
||||
.as_ref()
|
||||
.map(|c| c.data_dir.as_str())
|
||||
.unwrap_or(&crate::core::shared::utils::get_work_path());
|
||||
.unwrap_or(&work_path);
|
||||
|
||||
let final_path = match output_path {
|
||||
Some(path) => {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,8 @@ pub async fn login(
|
|||
})?;
|
||||
|
||||
// Try to get admin token: first PAT file, then OAuth client credentials
|
||||
let pat_path = std::path::Path::new(&format!("{}/conf/directory/admin-pat.txt", get_stack_path()));
|
||||
let stack = get_stack_path();
|
||||
let pat_path = std::path::PathBuf::from(format!("{}/conf/directory/admin-pat.txt", stack));
|
||||
let admin_token = std::fs::read_to_string(pat_path)
|
||||
.map(|s| s.trim().to_string())
|
||||
.unwrap_or_default();
|
||||
|
|
|
|||
|
|
@ -522,7 +522,8 @@ pub async fn run_axum_server(
|
|||
.layer(cors)
|
||||
.layer(TraceLayer::new_for_http());
|
||||
|
||||
let cert_dir = std::path::Path::new(&format!("{}/conf/system/certificates", crate::core::shared::utils::get_stack_path()));
|
||||
let stack = crate::core::shared::utils::get_stack_path();
|
||||
let cert_dir = std::path::PathBuf::from(format!("{}/conf/system/certificates", stack));
|
||||
let cert_path = cert_dir.join("api/server.crt");
|
||||
let key_path = cert_dir.join("api/server.key");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue