Skip to content
Snippets Groups Projects
Unverified Commit a4f54234 authored by Roel Janssen's avatar Roel Janssen
Browse files

download: Handle username and password properties for FTP URIs.

* guix/build/download.scm (ftp-fetch): Process username and password from a URI.
parent 193420a8
No related branches found
No related tags found
No related merge requests found
...@@ -241,7 +241,18 @@ (define (nar-uri-abbreviation uri) ...@@ -241,7 +241,18 @@ (define (nar-uri-abbreviation uri)
(define* (ftp-fetch uri file #:key timeout) (define* (ftp-fetch uri file #:key timeout)
"Fetch data from URI and write it to FILE. Return FILE on success. Bail "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." 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)))) (size (false-if-exception (ftp-size conn (uri-path uri))))
(in (ftp-retr conn (basename (uri-path uri)) (in (ftp-retr conn (basename (uri-path uri))
(dirname (uri-path uri))))) (dirname (uri-path uri)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment