aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-10-11 00:03:55 +0100
committerArun Isaac2024-10-11 00:06:14 +0100
commit2f3a764de2e12103cbb9c1fab43b67deaa5623df (patch)
treea59453e8729dfde14f0d4af6a3bd72752c542c2d
parentfa8ffbee3d931e8a9e6326f3d2e1d020c44fadf2 (diff)
downloadravanan-2f3a764de2e12103cbb9c1fab43b67deaa5623df.tar.gz
ravanan-2f3a764de2e12103cbb9c1fab43b67deaa5623df.tar.lz
ravanan-2f3a764de2e12103cbb9c1fab43b67deaa5623df.zip
command-line-tool: Compute hash of stdout file.
* ravanan/command-line-tool.scm (build-command-line-tool-script)[path+sha1->value]: New function. [path->value]: Implement in terms of path+sha1->value. [stdout-output->value]: Use path+sha1->value.
-rw-r--r--ravanan/command-line-tool.scm44
1 files changed, 27 insertions, 17 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index db2e45b..f2aec4a 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -820,10 +820,11 @@ directory of the workflow."
path)
secondary-file-value)))
- (define (path->value path workflow-output-directory maybe-secondary-files)
+ (define (path+sha1->value path sha1 workflow-output-directory maybe-secondary-files)
(maybe-assoc-set (copy-file-value (canonicalize-file-value
`(("class" . "File")
- ("path" . ,path)))
+ ("path" . ,path)
+ ("checksum" . ,(string-append "sha1$" sha1))))
workflow-output-directory)
(cons "secondaryFiles"
(maybe-let* ((secondary-files maybe-secondary-files))
@@ -833,26 +834,35 @@ directory of the workflow."
workflow-output-directory)
secondary-files))))))
+ (define (path->value path workflow-output-directory maybe-secondary-files)
+ (path+sha1->value path
+ (sha1-hash path)
+ workflow-output-directory
+ maybe-secondary-files))
+
(define (stdout-output->value workflow-output-directory
stdout-directory
stdout-filename
output)
(cons (assoc-ref output "id")
- (path->value
- (if (string=? stdout-filename
- (file-name-join* stdout-directory "stdout"))
- ;; If stdout filename is unspecified, rename it to a
- ;; hash of its contents.
- (let ((hashed-filename
- (file-name-join* stdout-directory
- (sha1-hash stdout-filename))))
- (rename-file stdout-filename
- hashed-filename)
- hashed-filename)
- ;; Else, return the stdout filename as it is.
- stdout-filename)
- workflow-output-directory
- %nothing)))
+ (let ((sha1 (sha1-hash stdout-filename)))
+ ;; Use path+sha1->value instead of path->value to avoid
+ ;; recomputing the SHA1 hash.
+ (path+sha1->value
+ (if (string=? stdout-filename
+ (file-name-join* stdout-directory "stdout"))
+ ;; If stdout filename is unspecified, rename it to a
+ ;; hash of its contents.
+ (let ((hashed-filename
+ (file-name-join* stdout-directory sha1)))
+ (rename-file stdout-filename
+ hashed-filename)
+ hashed-filename)
+ ;; Else, return the stdout filename as it is.
+ stdout-filename)
+ sha1
+ workflow-output-directory
+ %nothing))))
(define (other-output->value workflow-output-directory
output-id output-type-tree