start_command/
log_uploader.rs1use std::path::Path;
4
5use crate::execution_store::ExecutionStore;
6use crate::failure_handler::upload_log_interactive_with_options;
7
8pub fn upload_execution_log(
10 store: Option<&ExecutionStore>,
11 identifier: &str,
12) -> Result<i32, String> {
13 upload_execution_log_with_options(store, identifier, false, false)
14}
15
16pub fn upload_execution_log_with_options(
18 store: Option<&ExecutionStore>,
19 identifier: &str,
20 no_sanitize: bool,
21 verbose: bool,
22) -> Result<i32, String> {
23 let store = store.ok_or_else(|| "Execution tracking is disabled.".to_string())?;
24 let record = store.get(identifier).ok_or_else(|| {
25 format!(
26 "No execution found with UUID or session name: {}",
27 identifier
28 )
29 })?;
30
31 if let Some(chain_log) = crate::execution_chain::prepare_chain_upload(store, &record)? {
33 return upload_log_interactive_with_options(
34 &chain_log.path.to_string_lossy(),
35 no_sanitize,
36 verbose,
37 );
38 }
39
40 if record.log_path.is_empty() {
41 return Err("Execution record does not have a log path.".to_string());
42 }
43
44 if !Path::new(&record.log_path).exists() {
45 return Err(format!("Log file not found: {}", record.log_path));
46 }
47
48 upload_log_interactive_with_options(&record.log_path, no_sanitize, verbose)
49}