aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2025-04-23 15:08:21 +0100
committerArun Isaac2025-04-23 15:08:21 +0100
commit100e33ab0af01fd889df3844fa9de9aab7b59c7e (patch)
treec6523f124131eaa2fd0a2177ff9bb973d03ce550
parent6e499945abf03d928f56ad629d5aa6853ab4cdc5 (diff)
downloadravanan-main.tar.gz
ravanan-main.tar.lz
ravanan-main.zip
store: Intern files into a directory of their own.HEADmain
This way, user-supplied files and intermediate files generated by steps are stored the same way. Also, basename is preserved and there is no need to strip store hashes from filenames. * ravanan/command-line-tool.scm (copy-input-files-gexp): Use basename instead of store-item-name. * ravanan/store.scm (intern-file): Intern files into a directory of their own. (%store-hash-length, store-item-name): Delete variables. * ravanan/workflow.scm (resolve-inputs): Use basename instead of store-item-name.
-rw-r--r--ravanan/command-line-tool.scm2
-rw-r--r--ravanan/store.scm14
-rw-r--r--ravanan/workflow.scm4
3 files changed, 7 insertions, 13 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm
index c47bb3c..84b6421 100644
--- a/ravanan/command-line-tool.scm
+++ b/ravanan/command-line-tool.scm
@@ -493,7 +493,7 @@ The returned G-expression will reference an @code{inputs-directory} variable."
((eq? (object-type input)
'File)
#~,(let ((path-in-inputs-directory
- (expand-file-name #$(store-item-name (assoc-ref input "path"))
+ (expand-file-name #$(basename (assoc-ref input "path"))
inputs-directory)))
(copy-file #$(assoc-ref input "path")
path-in-inputs-directory)
diff --git a/ravanan/store.scm b/ravanan/store.scm
index 5cb4a64..00d26e6 100644
--- a/ravanan/store.scm
+++ b/ravanan/store.scm
@@ -31,8 +31,7 @@
script->store-data-file
script->store-stdout-file
script->store-stderr-file
- intern-file
- store-item-name))
+ intern-file))
(define %store-files-directory
"files")
@@ -110,7 +109,8 @@ interned path and location."
(file-name-join* %store-files-directory
(string-append sha1
"-"
- (basename path)))
+ (basename path))
+ (basename path))
store)))
(if (file-exists? interned-path)
(format (current-error-port)
@@ -120,6 +120,7 @@ interned path and location."
(format (current-error-port)
"Interning ~a into store as ~a~%"
path interned-path)
+ (mkdir (dirname interned-path))
;; Hard link if on the same filesystem. Else, copy.
((if (same-filesystem? path
(expand-file-name %store-files-directory
@@ -140,11 +141,4 @@ interned path and location."
(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 2770f31..5452ec4 100644
--- a/ravanan/workflow.scm
+++ b/ravanan/workflow.scm
@@ -455,8 +455,8 @@ files found into the @var{store} and return a tree of the fully resolved inputs.
"Return @code{#t} if @var{secondary-file} matches at least one secondary file in
@var{input}."
(vector-any (lambda (candidate)
- (string=? (store-item-name (assoc-ref* candidate "path"))
- (secondary-path (store-item-name (assoc-ref* input "path"))
+ (string=? (basename (assoc-ref* candidate "path"))
+ (secondary-path (basename (assoc-ref* input "path"))
secondary-file)))
(or (assoc-ref input "secondaryFiles")
(user-error "Missing secondaryFiles in input ~a"