diff --git a/.vscode/launch.json b/.vscode/launch.json index ef0fdff78..0a6f9b474 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,7 +14,7 @@ }, "args": [], "env": { - "RUST_LOG": "debug,actix_server=off,hyper_util=off,aws_smithy_runtime=off,aws_smithy_runtime_api=off,tracing=off,aws_sdk_s3=off" + "RUST_LOG": "debug,reqwest=off,aws_runtime=off,aws_smithy_http_client=off,rustls=off,actix_server=off,hyper_util=off,aws_smithy_runtime=off,aws_smithy_runtime_api=off,tracing=off,aws_sdk_s3=off" }, "cwd": "${workspaceFolder}" diff --git a/migrations/6.0.5.sql b/migrations/6.0.5.sql index b5c81b027..cbbab1e56 100644 --- a/migrations/6.0.5.sql +++ b/migrations/6.0.5.sql @@ -13,7 +13,7 @@ ALTER TABLE public.system_automations ADD COLUMN IF NOT EXISTS name VARCHAR(255) INSERT INTO public.system_automations (name, kind, target, param, schedule, is_active) VALUES ( 'Update Summary', - 3, + 0, NULL, 'update-summary.bas', '* * * * *', diff --git a/src/automation/mod.rs b/src/automation/mod.rs index 377dc9e23..d9b8cbd1a 100644 --- a/src/automation/mod.rs +++ b/src/automation/mod.rs @@ -175,7 +175,7 @@ impl AutomationService { ); for automation in automations { if let Some(TriggerKind::Scheduled) = TriggerKind::from_i32(automation.kind) { - debug!( + trace!( "Evaluating schedule pattern={:?} for automation {}", automation.schedule, automation.id @@ -190,7 +190,7 @@ impl AutomationService { self.execute_action(&automation.param).await; self.update_last_triggered(automation.id).await; } else { - debug!("Pattern did not match for automation {}", automation.id); + trace!("Pattern did not match for automation {}", automation.id); } } } @@ -336,10 +336,11 @@ impl AutomationService { } }; - let path_str = format!("./work/{}.gbai/{}.gbdialog/{}", + let script_name = param.strip_suffix(".bas").unwrap_or(param); + let path_str = format!("./work/{}.gbai/{}.gbdialog/{}.ast", bot_name, bot_name, - param + script_name ); let full_path = Path::new(&path_str); trace!("Resolved full path: {}", full_path.display()); @@ -350,56 +351,14 @@ impl AutomationService { content } Err(e) => { - warn!( - "Script not found locally at {}, attempting to download from MinIO: {}", + error!( + "Failed to read script '{}' at {}: {}", + param, full_path.display(), e ); - - if let Some(client) = &self.state.drive { - let bucket_name = format!( - "{}.gbai", - crate::bot::get_default_bot(&mut self.state.conn.lock().unwrap()).0.to_string() - ); - let s3_key = format!(".gbdialog/{}", param); - - trace!("Downloading from bucket={} key={}", bucket_name, s3_key); - - match crate::kb::minio_handler::get_file_content(client, &bucket_name, &s3_key).await { - Ok(data) => { - match String::from_utf8(data) { - Ok(content) => { - info!("Downloaded script '{}' from MinIO", param); - - // Save to local cache - if let Err(e) = std::fs::create_dir_all(&self.scripts_dir) { - warn!("Failed to create scripts directory: {}", e); - } else if let Err(e) = tokio::fs::write(&full_path, &content).await { - warn!("Failed to cache script locally: {}", e); - } else { - trace!("Cached script to {}", full_path.display()); - } - - content - } - Err(e) => { - error!("Failed to decode script {}: {}", param, e); - self.cleanup_job_flag(&bot_id, param).await; - return; - } - } - } - Err(e) => { - error!("Failed to download script {} from MinIO: {}", param, e); - self.cleanup_job_flag(&bot_id, param).await; - return; - } - } - } else { - error!("S3 client not available, cannot download script {}", param); - self.cleanup_job_flag(&bot_id, param).await; - return; - } + self.cleanup_job_flag(&bot_id, param).await; + return; } };