guix-commits
[Top][All Lists]
Advanced

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

02/02: download: Handle username and password properties for FTP URIs.


From: Roel Janssen
Subject: 02/02: download: Handle username and password properties for FTP URIs.
Date: Tue, 21 Mar 2017 07:15:54 -0400 (EDT)

roelj pushed a commit to branch master
in repository guix.

commit a4f542341511f33ece18d16b68118214da8143ec
Author: Roel Janssen <address@hidden>
Date:   Tue Mar 21 12:15:14 2017 +0100

    download: Handle username and password properties for FTP URIs.
    
    * guix/build/download.scm (ftp-fetch): Process username and password from a 
URI.
---
 guix/build/download.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/guix/build/download.scm b/guix/build/download.scm
index 36c815c..c5dddf8 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -241,7 +241,18 @@ and 'guix publish', something like
 (define* (ftp-fetch uri file #:key timeout)
   "Fetch data from URI and write it to FILE.  Return FILE on success.  Bail
 out if the connection could not be established in less than TIMEOUT seconds."
-  (let* ((conn (ftp-open (uri-host uri) #:timeout timeout))
+  (let* ((userinfo (string-split (uri-userinfo uri) #\:))
+         (conn (match userinfo
+                 (("")
+                  (ftp-open (uri-host uri) #:timeout timeout))
+                 (((? string? user))
+                  (ftp-open (uri-host uri) #:timeout timeout
+                                           #:username user))
+                 (((? string? user) (? string? pass))
+                  (ftp-open (uri-host uri) #:timeout timeout
+                                           #:username user
+                                           #:password pass))
+                 (_ (ftp-open (uri-host uri) #:timeout timeout))))
          (size (false-if-exception (ftp-size conn (uri-path uri))))
          (in   (ftp-retr conn (basename (uri-path uri))
                          (dirname (uri-path uri)))))



reply via email to

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