download: Don't abbreviate things that are not store items.

Fixes a regression introduced in a8be7b9a.

* guix/build/download.scm (store-path-abbreviation): Return STORE-PATH
  if it's not an actual store path.  Fixes an out-of-range exception
  when running tests/substitute.scm and tests/store.scm.
master
Ludovic Courtès 2015-09-24 21:54:37 +02:00
parent 7a8ac75a94
commit 75726135ce
1 changed files with 9 additions and 6 deletions

View File

@ -111,12 +111,15 @@ column."
(string-append left padding right)))
(define* (store-path-abbreviation store-path #:optional (prefix-length 6))
"Return an abbreviation of STORE-PATH for display, showing PREFIX-LENGTH
characters of the hash."
(let ((base (basename store-path)))
(string-append (string-take base prefix-length)
"…"
(string-drop base 32))))
"If STORE-PATH is the file name of a store entry, return an abbreviation of
STORE-PATH for display, showing PREFIX-LENGTH characters of the hash.
Otherwise return STORE-PATH."
(if (string-prefix? (%store-directory) store-path)
(let ((base (basename store-path)))
(string-append (string-take base prefix-length)
"…"
(string-drop base 32)))
store-path))
(define* (progress-proc file size
#:optional (log-port (current-output-port))