From 7f265bf2057f80d53656903b9fc3951beb28b57d Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Fri, 17 Apr 2026 10:48:35 -0300 Subject: [PATCH] fix: tables.bas only if changed, clean drive monitor logs --- src/basic/compiler/mod.rs | 31 ++++++++++++++++++++++++++++--- src/drive/drive_monitor/mod.rs | 17 +++++++++-------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/basic/compiler/mod.rs b/src/basic/compiler/mod.rs index 378a9504..755a908c 100644 --- a/src/basic/compiler/mod.rs +++ b/src/basic/compiler/mod.rs @@ -116,9 +116,34 @@ impl BasicCompiler { let source_content = fs::read_to_string(source_path) .map_err(|e| format!("Failed to read source file: {e}"))?; - // Also process tables.bas to ensure tables are created - if let Err(e) = Self::process_tables_bas(&self.state, self.bot_id) { - log::warn!("Failed to process tables.bas: {}", e); + // Check if tables.bas has changed by comparing .bas vs .ast modification time + // Only process if .bas is newer than .ast or .ast doesn't exist + let should_process_tables = if source_path.contains("tables.bas") { + let work_path = crate::core::shared::utils::get_work_path(); + let bot_name = Self::get_bot_name_from_state(&self.state, self.bot_id)?; + let tables_bas_path = format!( + "{}/{}.gbai/{}.gbdialog/tables.bas", + work_path, bot_name, bot_name + ); + let tables_ast_path = tables_bas_path.replace(".bas", ".ast"); + + match ( + std::fs::metadata(&tables_bas_path).ok(), + std::fs::metadata(&tables_ast_path).ok(), + ) { + (Some(bas_meta), Some(ast_meta)) => { + bas_meta.modified().ok() > ast_meta.modified().ok() + } + _ => true, + } + } else { + true + }; + + if should_process_tables { + if let Err(e) = Self::process_tables_bas(&self.state, self.bot_id) { + log::warn!("Failed to process tables.bas: {}", e); + } } if let Err(e) = diff --git a/src/drive/drive_monitor/mod.rs b/src/drive/drive_monitor/mod.rs index de9cf215..10ec9eae 100644 --- a/src/drive/drive_monitor/mod.rs +++ b/src/drive/drive_monitor/mod.rs @@ -437,6 +437,7 @@ match result { } self.is_processing.store(true, Ordering::Release); + trace!("DriveMonitor checking {}", self.bucket_name); match self.check_for_changes().await { Ok(_) => { @@ -463,14 +464,14 @@ match result { }; // All checks run independently - one failure doesn't stop others - if let Err(e) = self.check_gbdialog_changes(client).await { - error!("gbdialog check failed: {}", e); - } - if let Err(e) = self.check_gbot(client).await { - error!("gbot check failed: {}", e); - } - if let Err(e) = self.check_gbkb_changes(client).await { - error!("gbkb check failed: {}", e); + let gbdialog_err = self.check_gbdialog_changes(client).await.err(); + let gbot_err = self.check_gbot(client).await.err(); + let gbkb_err = self.check_gbkb_changes(client).await.err(); + + if gbdialog_err.is_some() || gbot_err.is_some() || gbkb_err.is_some() { + error!("Drive changes: gbdialog={:?}, gbot={:?}, gbkb={:?}", gbdialog_err, gbot_err, gbkb_err); + } else { + trace!("DriveMonitor: 0 changes for {}", self.bucket_name); } Ok(())