Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(convert): treat a missing job folder as cleaned up (#7885)
teo37d59a9389a3
diff --git a/services/convert_service/src/process/convert.rs b/services/convert_service/src/process/convert.rsindex 67e4a75f32..97abb8adfd 100644--- a/services/convert_service/src/process/convert.rs+++ b/services/convert_service/src/process/convert.rs@@ -294,9 +294,6 @@ pub(crate) fn run_lok_conversion(if status_code != 0 {tracing::error!(job_id=%job_id, status=status_code, "conversion failed with non-zero status code");- if let Err(e) = cleanup_folder(job_id) {- tracing::error!(error=?e, job_id=%job_id, "unable to cleanup folder");- }anyhow::bail!("conversion failed");}diff --git a/services/convert_service/src/process/test.rs b/services/convert_service/src/process/test.rsindex 16d49f1fa9..4d8cff3f9d 100644--- a/services/convert_service/src/process/test.rs+++ b/services/convert_service/src/process/test.rs@@ -366,3 +366,47 @@ mod conversion_table {assert!(resolve_file_type(None, "macro|[email protected]/doc/12").is_err());}}++mod job_cleanup {+ //! Tests `remove_job_folder` directly: CI builds with `--all-features`,+ //! where `disable_cleanup` turns `cleanup_folder` into a no-op.++ use std::path::Path;++ use crate::utils::remove_job_folder;++ /// Removes a job folder prepared by `setup` and checks the outcome.+ fn check(setup: fn(&Path), expect_ok: bool) {+ let root = tempfile::tempdir().unwrap();+ let job = root.path().join("job");+ setup(&job);++ let result = remove_job_folder(job.to_str().unwrap());++ assert_eq!(result.is_ok(), expect_ok, "{result:?}");+ if expect_ok {+ assert!(!job.exists());+ }+ }++ #[test]+ fn removes_the_job_folder() {+ check(+ |job| {+ std::fs::create_dir(job).unwrap();+ std::fs::write(job.join("IN.docx"), b"input").unwrap();+ },+ true,+ );+ }++ #[test]+ fn a_job_that_failed_before_creating_its_folder_cleans_up() {+ check(|_| {}, true);+ }++ #[test]+ fn other_failures_still_surface() {+ check(|job| std::fs::write(job, b"not a folder").unwrap(), false);+ }+}diff --git a/services/convert_service/src/utils.rs b/services/convert_service/src/utils.rsindex abd3b5ca31..ff314b038f 100644--- a/services/convert_service/src/utils.rs+++ b/services/convert_service/src/utils.rs@@ -11,8 +11,18 @@ pub fn cleanup_folder(job_id: &str) -> anyhow::Result<()> {return Ok(());}tracing::trace!(job_id=%job_id, "cleaning up job");- std::fs::remove_dir_all(job_id).context("unable to remove directory")?;- Ok(())+ remove_job_folder(job_id)+}++/// Removes a job folder. A job that failed before creating its folder has+/// nothing to remove.+pub(crate) fn remove_job_folder(path: &str) -> anyhow::Result<()> {+ match std::fs::remove_dir_all(path) {+ Err(e) if e.kind() != std::io::ErrorKind::NotFound => {+ Err(e).context("unable to remove directory")+ }+ _ => Ok(()),+ }}/// LibreOfficeKit filter options for a supported conversion.