From 993ebca4245c97268a418ab683adb820839e666f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 14 Apr 2025 18:00:07 +0100 Subject: store: Intern secondary files. * ravanan/store.scm: Import (srfi srfi-26) and (ravanan work vectors). (intern-file): Intern secondary files. (%store-hash-length): New variable. (store-item-name): New public function. * ravanan/workflow.scm (resolve-inputs)[match-secondary-file-pattern]: Strip store hashes before matching secondary file patterns. --- ravanan/store.scm | 21 +++++++++++++++++++-- ravanan/workflow.scm | 4 ++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ravanan/store.scm b/ravanan/store.scm index abe8891..ae614fd 100644 --- a/ravanan/store.scm +++ b/ravanan/store.scm @@ -17,9 +17,11 @@ ;;; along with ravanan. If not, see . (define-module (ravanan store) + #:use-module (srfi srfi-26) #:use-module (ice-9 filesystem) #:use-module (ravanan work command-line-tool) #:use-module (ravanan work monads) + #:use-module (ravanan work vectors) #:export (%store-files-directory %store-data-directory %store-logs-directory @@ -29,7 +31,8 @@ script->store-data-file script->store-stdout-file script->store-stderr-file - intern-file)) + intern-file + store-item-name)) (define %store-files-directory "files") @@ -127,4 +130,18 @@ interned path and location." interned-path)))) (maybe-assoc-set file (cons "location" (just (string-append "file://" interned-path))) - (cons "path" (just interned-path))))) + (cons "path" (just interned-path)) + (cons "secondaryFiles" + (maybe-let* ((secondary-files (maybe-assoc-ref (just file) + "secondaryFiles"))) + (just (vector-map (cut intern-file <> store) + secondary-files))))))) + +;; Length of a base-16 encoded SHA1 hash +(define %store-hash-length 40) + +(define (store-item-name path) + "Return the basename of store item @var{path} with the store hash stripped out." + (string-drop (basename path) + ;; the hash and the dash after the hash + (1+ %store-hash-length))) diff --git a/ravanan/workflow.scm b/ravanan/workflow.scm index 3fc6ec6..fff69f5 100644 --- a/ravanan/workflow.scm +++ b/ravanan/workflow.scm @@ -456,8 +456,8 @@ files found into the @var{store} and return a tree of the fully resolved inputs. file in @var{input}." ;; TODO: Implement caret characters in SecondaryFileSchema DSL. (vector-any (lambda (secondary-file) - (string=? (assoc-ref* secondary-file "path") - (string-append (assoc-ref* input "path") + (string=? (store-item-name (assoc-ref* secondary-file "path")) + (string-append (store-item-name (assoc-ref* input "path")) pattern))) (or (assoc-ref input "secondaryFiles") (user-error "Missing secondaryFiles in input ~a" -- cgit v1.2.3