mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-26 06:18:07 -05:00
substitute: Gracefully handle invalid store file names.
Before, something like: echo have /gnu/foo | ./test-env guix substitute --query would lead to an ugly backtrace. * guix/scripts/substitute.scm (narinfo-cache-file): Call 'leave' when 'store-hash-part' returns #f.
This commit is contained in:
parent
a773c3142d
commit
30d4bc0434
1 changed files with 9 additions and 3 deletions
|
@ -440,9 +440,15 @@ (define (obsolete? date now ttl)
|
||||||
(define (narinfo-cache-file cache-url path)
|
(define (narinfo-cache-file cache-url path)
|
||||||
"Return the name of the local file that contains an entry for PATH. The
|
"Return the name of the local file that contains an entry for PATH. The
|
||||||
entry is stored in a sub-directory specific to CACHE-URL."
|
entry is stored in a sub-directory specific to CACHE-URL."
|
||||||
(string-append %narinfo-cache-directory "/"
|
;; The daemon does not sanitize its input, so PATH could be something like
|
||||||
(bytevector->base32-string (sha256 (string->utf8 cache-url)))
|
;; "/gnu/store/foo". Gracefully handle that.
|
||||||
"/" (store-path-hash-part path)))
|
(match (store-path-hash-part path)
|
||||||
|
(#f
|
||||||
|
(leave (_ "'~a' does not name a store item~%") path))
|
||||||
|
((? string? hash-part)
|
||||||
|
(string-append %narinfo-cache-directory "/"
|
||||||
|
(bytevector->base32-string (sha256 (string->utf8 cache-url)))
|
||||||
|
"/" hash-part))))
|
||||||
|
|
||||||
(define (cached-narinfo cache-url path)
|
(define (cached-narinfo cache-url path)
|
||||||
"Check locally if we have valid info about PATH coming from CACHE-URL.
|
"Check locally if we have valid info about PATH coming from CACHE-URL.
|
||||||
|
|
Loading…
Reference in a new issue