From 85c561053241ee4ee4c7567324e4080b6fcc2a5a Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 13 Sep 2024 02:25:10 +0100 Subject: 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. --- ravanan/command-line-tool.scm | 25 +++++++++++++++---------- 1 file 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 -- cgit v1.2.3