From 15065f4bb08c92100ff3e2cb159b9ed73612ee2c Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 21 Jan 2025 14:18:41 +0000 Subject: command-line-tool: Write output JSON atomically to the store. * ravanan/command-line-tool.scm (run-command-line-tool, build-command-line-tool-script): Write output JSON atomically to the store. --- ravanan/command-line-tool.scm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index a5b800f..a56241b 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -395,7 +395,6 @@ state-monadic job state object. @var{channels}, @var{scratch}, @var{store}, @var{batch-system} and @var{guix-daemon-socket} are the same as in @code{run-workflow} from @code{(ravanan workflow)}." - ;; TODO: Write to the store atomically. (let* ((script (build-command-line-tool-script name manifest-file channels cwl inputs scratch store batch-system @@ -481,7 +480,7 @@ state-monadic job state object. (output-json (call-with-input-file store-data-file json->scm))) ;; Recursively rewrite file paths in output JSON. - (call-with-output-file store-data-file + (call-with-atomic-output-file store-data-file (lambda (port) (scm->json (let rewrite ((tree output-json)) (cond @@ -767,7 +766,7 @@ same as in @code{run-workflow} from @code{(ravanan workflow)}." (define capture-outputs-gexp #~(let ((workflow-output-directory (getenv "WORKFLOW_OUTPUT_DIRECTORY"))) - (call-with-output-file (getenv "WORKFLOW_OUTPUT_DATA_FILE") + (call-with-atomic-output-file (getenv "WORKFLOW_OUTPUT_DATA_FILE") (lambda (out) (scm->json (if (file-exists? "cwl.output.json") -- cgit v1.2.3