diff options
author | Arun Isaac | 2024-09-13 02:25:10 +0100 |
---|---|---|
committer | Arun Isaac | 2024-09-13 02:57:39 +0100 |
commit | 85c561053241ee4ee4c7567324e4080b6fcc2a5a (patch) | |
tree | 518f33b16361cd6d1aa59ded8cfa49885d3acb56 | |
parent | df457bed1053ee00985a628b4aec66a9538cee9e (diff) | |
download | ravanan-85c561053241ee4ee4c7567324e4080b6fcc2a5a.tar.gz ravanan-85c561053241ee4ee4c7567324e4080b6fcc2a5a.tar.lz ravanan-85c561053241ee4ee4c7567324e4080b6fcc2a5a.zip |
command-line-tool: Do not re-intern already interned files.
* ravanan/command-line-tool.scm (intern-file): Intern file only if it
is not already in the store.
-rw-r--r-- | ravanan/command-line-tool.scm | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/ravanan/command-line-tool.scm b/ravanan/command-line-tool.scm index 744ace3..14f9269 100644 --- a/ravanan/command-line-tool.scm +++ b/ravanan/command-line-tool.scm @@ -620,16 +620,21 @@ path." json->scm))) (define (intern-file file store) - "Intern @var{file} into the ravanan @var{store}. Return the interned path." - (let ((interned-path - (expand-file-name - (file-name-join* %store-files-directory - (string-append (sha1-hash file) - "-" - (basename file))) - store))) - (copy-file file interned-path) - interned-path)) + "Intern @var{file} into the ravanan @var{store} unless it is already a store +path. Return the interned path." + (if (string-prefix? store file) + ;; If file is already a store path, return it as is. + file + ;; Else, intern it and return the interned path. + (let ((interned-path + (expand-file-name + (file-name-join* %store-files-directory + (string-append (sha1-hash file) + "-" + (basename file))) + store))) + (copy-file file interned-path) + interned-path))) (define (copy-input-files-gexp inputs) "Return a G-expression that copies @code{File} type inputs from @var{inputs} into |