From 26b009d4e662d0520fd64567b5bc92d516ba9ce7 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Fri, 10 Apr 2026 11:31:17 -0300 Subject: [PATCH] Fix: Remove duplicate method definitions in DriveMonitor - Removed duplicate file_state_path() and load_file_states() methods - Kept only new save_file_states_static() helper - Original methods still exist at lines 79-84 and 87-128 - Fixes compilation errors from previous commit --- src/drive/drive_monitor/mod.rs | 92 ---------------------------------- 1 file changed, 92 deletions(-) diff --git a/src/drive/drive_monitor/mod.rs b/src/drive/drive_monitor/mod.rs index d347ae44..b5435997 100644 --- a/src/drive/drive_monitor/mod.rs +++ b/src/drive/drive_monitor/mod.rs @@ -127,13 +127,6 @@ impl DriveMonitor { Ok(()) } - /// Get the path to the file states JSON file for this bot - fn file_state_path(&self) -> PathBuf { - self.work_root - .join(format!("{}", self.bot_id)) - .join("file_states.json") - } - /// Static helper to save file states (used by background tasks) async fn save_file_states_static( file_states: &Arc>>, @@ -181,91 +174,6 @@ impl DriveMonitor { Ok(()) } - /// Load file states from disk to avoid reprocessing unchanged files - async fn load_file_states(&self) -> Result<(), Box> { - let path = self.file_state_path(); - if path.exists() { - match tokio_fs::read_to_string(&path).await { - Ok(content) => { - match serde_json::from_str::>(&content) { - Ok(states) => { - let mut file_states = self.file_states.write().await; - let count = states.len(); - *file_states = states; - trace!( - "[DRIVE_MONITOR] Loaded {} file states from disk for bot {}", - count, - self.bot_id - ); - } - Err(e) => { - warn!( - "[DRIVE_MONITOR] Failed to parse file states from {}: {}. Starting with empty state.", - path.display(), - e - ); - } - } - } - Err(e) => { - warn!( - "[DRIVE_MONITOR] Failed to read file states from {}: {}. Starting with empty state.", - path.display(), - e - ); - } - } - } else { - debug!( - "[DRIVE_MONITOR] No existing file states found at {} for bot {}. Starting fresh.", - path.display(), - self.bot_id - ); - } - Ok(()) - } - - /// Save file states to disk after updates - async fn save_file_states(&self) -> Result<(), Box> { - let path = self.file_state_path(); - - if let Some(parent) = path.parent() { - if let Err(e) = tokio_fs::create_dir_all(parent).await { - warn!( - "[DRIVE_MONITOR] Failed to create directory for file states: {} - {}", - parent.display(), - e - ); - } - } - - let file_states = self.file_states.read().await; - match serde_json::to_string_pretty(&*file_states) { - Ok(content) => { - if let Err(e) = tokio_fs::write(&path, content).await { - warn!( - "[DRIVE_MONITOR] Failed to save file states to {}: {}", - path.display(), - e - ); - } else { - debug!( - "[DRIVE_MONITOR] Saved {} file states to disk for bot {}", - file_states.len(), - self.bot_id - ); - } - } - Err(e) => { - warn!( - "[DRIVE_MONITOR] Failed to serialize file states: {}", - e - ); - } - } - Ok(()) - } - async fn check_drive_health(&self) -> bool { let Some(client) = &self.state.drive else { return false;