deduplicate: Create the '.links' directory lazily.
This avoids repeated (mkdir-p "/gnu/store/.links") calls when deduplicating lots of files. * guix/store/deduplication.scm (deduplicate): Remove initial call to 'mkdir-p'. Add ENOENT case in 'link' exception handler. Reindent. * tests/store-deduplication.scm ("deduplicate, ENOSPC"): Check for (<= links 4) to account for the initial 'link' call.
This commit is contained in:
parent
9e6fe0e08f
commit
7530e491b5
2 changed files with 51 additions and 47 deletions
|
@ -159,7 +159,6 @@ under STORE."
|
|||
(define links-directory
|
||||
(string-append store "/.links"))
|
||||
|
||||
(mkdir-p links-directory)
|
||||
(let loop ((path path)
|
||||
(type (stat:type (lstat path)))
|
||||
(hash hash))
|
||||
|
@ -195,6 +194,11 @@ under STORE."
|
|||
#:swap-directory
|
||||
links-directory
|
||||
#:store store))
|
||||
((= errno ENOENT)
|
||||
;; This most likely means that LINKS-DIRECTORY does
|
||||
;; not exist. Attempt to create it and try again.
|
||||
(mkdir-p links-directory)
|
||||
(loop path type hash))
|
||||
((= errno ENOSPC)
|
||||
;; There's not enough room in the directory index for
|
||||
;; more entries in .links, but that's fine: we can
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
(lambda ()
|
||||
(set! link (lambda (old new)
|
||||
(set! links (+ links 1))
|
||||
(if (<= links 3)
|
||||
(if (<= links 4)
|
||||
(true-link old new)
|
||||
(throw 'system-error "link" "~A" '("Whaaat?!")
|
||||
(list ENOSPC))))))
|
||||
|
|
Reference in a new issue