mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 05:18:07 -05:00
guix download: Support retrieving local file without the URI scheme.
* guix/scripts/download.scm (guix-download): Treat the URL argument as a local file path when it fails on 'string->uri'. Call 'fetch' with the processed 'uri' instead of the original URL argument. * tests/guix-download.sh: Adjust accordingly.
This commit is contained in:
parent
6d7d9d9507
commit
a02967d77a
2 changed files with 8 additions and 2 deletions
|
@ -143,12 +143,15 @@ (define (parse-options)
|
||||||
(arg (or (assq-ref opts 'argument)
|
(arg (or (assq-ref opts 'argument)
|
||||||
(leave (G_ "no download URI was specified~%"))))
|
(leave (G_ "no download URI was specified~%"))))
|
||||||
(uri (or (string->uri arg)
|
(uri (or (string->uri arg)
|
||||||
|
(false-if-exception
|
||||||
|
(string->uri
|
||||||
|
(string-append "file://" (canonicalize-path arg))))
|
||||||
(leave (G_ "~a: failed to parse URI~%")
|
(leave (G_ "~a: failed to parse URI~%")
|
||||||
arg)))
|
arg)))
|
||||||
(fetch (assq-ref opts 'download-proc))
|
(fetch (assq-ref opts 'download-proc))
|
||||||
(path (parameterize ((current-terminal-columns
|
(path (parameterize ((current-terminal-columns
|
||||||
(terminal-columns)))
|
(terminal-columns)))
|
||||||
(fetch arg
|
(fetch (uri->string uri)
|
||||||
#:verify-certificate?
|
#:verify-certificate?
|
||||||
(assq-ref opts 'verify-certificate?))))
|
(assq-ref opts 'verify-certificate?))))
|
||||||
(hash (call-with-input-file
|
(hash (call-with-input-file
|
||||||
|
|
|
@ -29,12 +29,15 @@ then false; else true; fi
|
||||||
if guix download unknown://some/where;
|
if guix download unknown://some/where;
|
||||||
then false; else true; fi
|
then false; else true; fi
|
||||||
|
|
||||||
if guix download not/a/uri;
|
if guix download /does-not-exist
|
||||||
then false; else true; fi
|
then false; else true; fi
|
||||||
|
|
||||||
# This one should succeed.
|
# This one should succeed.
|
||||||
guix download "file://$abs_top_srcdir/README"
|
guix download "file://$abs_top_srcdir/README"
|
||||||
|
|
||||||
|
# And this one, without the URI scheme.
|
||||||
|
guix download "$abs_top_srcdir/README"
|
||||||
|
|
||||||
# This one too, even if it cannot talk to the daemon.
|
# This one too, even if it cannot talk to the daemon.
|
||||||
output="t-download-$$"
|
output="t-download-$$"
|
||||||
trap 'rm -f "$output"' EXIT
|
trap 'rm -f "$output"' EXIT
|
||||||
|
|
Loading…
Reference in a new issue