From d320b9cbdace1d00fddfc082df27d87c21664eca Mon Sep 17 00:00:00 2001 From: kiwigitops Date: Thu, 28 May 2026 15:25:34 -0400 Subject: [PATCH] make temporary cleanup nonfatal Signed-off-by: kiwigitops --- src/trace.ml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/trace.ml b/src/trace.ml index 4d0004703..28aa175e2 100644 --- a/src/trace.ml +++ b/src/trace.ml @@ -572,6 +572,18 @@ module Make_commands (Backend : Backend_intf.S) = struct and backend_opts = Backend.Record_opts.param and collection_mode = Collection_mode.param in fun ~executable ~f -> + let cleanup_record_dir record_dir = + match%map Monitor.try_with (fun () -> + Shell.rm ~r:() ~f:() record_dir; + Deferred.unit) + with + | Ok () -> () + | Error exn -> + eprintf + "[ Warning: failed to remove temporary working directory %s: %s ]\n%!" + record_dir + (Exn.to_string exn) + in let record_dir, cleanup = match record_dir with | Some dir -> @@ -581,8 +593,7 @@ module Make_commands (Backend : Backend_intf.S) = struct in Monitor.protect ~finally:(fun () -> - if cleanup then Shell.rm ~r:() ~f:() record_dir; - Deferred.unit) + if cleanup then cleanup_record_dir record_dir else Deferred.unit) (fun () -> f { Record_opts.backend_opts