aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-04-14 18:00:07 +0100
committerArun Isaac2025-04-14 18:00:07 +0100
commit993ebca4245c97268a418ab683adb820839e666f (patch)
treec6b5892494c9e44a0e77340fa67aa97c035f61ab
parentd2329d6da234edf2becbf862a9f63c4e067596f9 (diff)
downloadravanan-993ebca4245c97268a418ab683adb820839e666f.tar.gz
ravanan-993ebca4245c97268a418ab683adb820839e666f.tar.lz
ravanan-993ebca4245c97268a418ab683adb820839e666f.zip
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.
-rw-r--r--ravanan/store.scm21
-rw-r--r--ravanan/workflow.scm4
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 <https://www.gnu.org/licenses/>.
(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"