Skip to main content

start_command/
log_uploader.rs

1//! Helpers for uploading tracked execution logs.
2
3use std::path::Path;
4
5use crate::execution_store::ExecutionStore;
6use crate::failure_handler::upload_log_interactive;
7
8/// Upload the log for a stored execution by UUID or session name.
9pub fn upload_execution_log(
10    store: Option<&ExecutionStore>,
11    identifier: &str,
12) -> Result<i32, String> {
13    let store = store.ok_or_else(|| "Execution tracking is disabled.".to_string())?;
14    let record = store.get(identifier).ok_or_else(|| {
15        format!(
16            "No execution found with UUID or session name: {}",
17            identifier
18        )
19    })?;
20
21    if record.log_path.is_empty() {
22        return Err("Execution record does not have a log path.".to_string());
23    }
24
25    if !Path::new(&record.log_path).exists() {
26        return Err(format!("Log file not found: {}", record.log_path));
27    }
28
29    upload_log_interactive(&record.log_path)
30}