diff options
author | Ludovic Courtès <ludovic.courtes@inria.fr> | 2017-06-12 15:38:49 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-06-12 17:53:51 +0200 |
commit | b46712159c15f72fc28b71d17d5a7c74fcb64ed0 (patch) | |
tree | c5c0ff7449e9b267eb6c58593fc22b3fc35b74f7 | |
parent | 1243aaac732abc9b02f7dd3788b45e5f8f7b8cf7 (diff) | |
download | patches-b46712159c15f72fc28b71d17d5a7c74fcb64ed0.tar patches-b46712159c15f72fc28b71d17d5a7c74fcb64ed0.tar.gz |
store: Speed up 'add-to-store'.
* guix/store.scm (add-to-store): Remove 'lstat' call.
-rw-r--r-- | guix/store.scm | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/guix/store.scm b/guix/store.scm index c94dfea959..ed588aae47 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -830,10 +830,11 @@ bits are kept. HASH-ALGO must be a string such as \"sha256\". When RECURSIVE? is true, call (SELECT? FILE STAT) for each directory entry, where FILE is the entry's absolute file name and STAT is the result of 'lstat'; exclude entries for which SELECT? does not return true." - (let* ((st (false-if-exception (lstat file-name))) - (args `(,st ,basename ,recursive? ,hash-algo ,select?)) + ;; Note: We don't stat FILE-NAME at each call, and thus we assume that + ;; the file remains unchanged for the lifetime of SERVER. + (let* ((args `(,file-name ,basename ,recursive? ,hash-algo ,select?)) (cache (nix-server-add-to-store-cache server))) - (or (and st (hash-ref cache args)) + (or (hash-ref cache args) (let ((path (add-to-store server basename recursive? hash-algo file-name #:select? select?))) |