guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: guix download: Support retrieving local file without the URI sche


From: ???
Subject: 01/01: guix download: Support retrieving local file without the URI scheme.
Date: Sun, 20 Aug 2017 08:56:06 -0400 (EDT)

iyzsong pushed a commit to branch master
in repository guix.

commit a02967d77af03d6468e25d6e26dbea0db919ce96
Author: 宋文武 <address@hidden>
Date:   Sat Aug 19 20:41:44 2017 +0800

    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.
---
 guix/scripts/download.scm | 5 ++++-
 tests/guix-download.sh    | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index bb3dc76..f40213b 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -143,12 +143,15 @@ Supported formats: 'nix-base32' (default), 'base32', and 
'base16'
            (arg   (or (assq-ref opts 'argument)
                       (leave (G_ "no download URI was specified~%"))))
            (uri   (or (string->uri arg)
+                      (false-if-exception
+                       (string->uri
+                        (string-append "file://" (canonicalize-path arg))))
                       (leave (G_ "~a: failed to parse URI~%")
                              arg)))
            (fetch (assq-ref opts 'download-proc))
            (path  (parameterize ((current-terminal-columns
                                   (terminal-columns)))
-                    (fetch arg
+                    (fetch (uri->string uri)
                            #:verify-certificate?
                            (assq-ref opts 'verify-certificate?))))
            (hash  (call-with-input-file
diff --git a/tests/guix-download.sh b/tests/guix-download.sh
index ebc853c..30f55fb 100644
--- a/tests/guix-download.sh
+++ b/tests/guix-download.sh
@@ -29,12 +29,15 @@ then false; else true; fi
 if guix download unknown://some/where;
 then false; else true; fi
 
-if guix download not/a/uri;
+if guix download /does-not-exist
 then false; else true; fi
 
 # This one should succeed.
 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.
 output="t-download-$$"
 trap 'rm -f "$output"' EXIT



reply via email to

[Prev in Thread] Current Thread [Next in Thread]