ftp-client: `ftp-chdir' changes one step at a time.
* guix/ftp-client.scm (%char-set:not-slash): New variable. (ftp-chdir): Add docstring. Change to DIR one step at a time. (ftp-retr): Fix indentation.
This commit is contained in:
		
							parent
							
								
									accf7a373e
								
							
						
					
					
						commit
						87dfd45594
					
				
					 1 changed files with 24 additions and 11 deletions
				
			
		|  | @ -130,9 +130,22 @@ or a TCP port number), and return it." | ||||||
| (define (ftp-close conn) | (define (ftp-close conn) | ||||||
|   (close (ftp-connection-socket conn))) |   (close (ftp-connection-socket conn))) | ||||||
| 
 | 
 | ||||||
|  | (define %char-set:not-slash | ||||||
|  |   (char-set-complement (char-set #\/))) | ||||||
|  | 
 | ||||||
| (define (ftp-chdir conn dir) | (define (ftp-chdir conn dir) | ||||||
|  |   "Change to directory DIR." | ||||||
|  | 
 | ||||||
|  |   ;; On ftp.gnupg.org, "PASV" right after "CWD /gcrypt/gnupg" hangs.  Doing | ||||||
|  |   ;; CWD in two steps works, so just do this. | ||||||
|  |   (let ((components (string-tokenize dir %char-set:not-slash))) | ||||||
|  |     (fold (lambda (dir result) | ||||||
|             (%ftp-command (string-append "CWD " dir) 250 |             (%ftp-command (string-append "CWD " dir) 250 | ||||||
|                           (ftp-connection-socket conn))) |                           (ftp-connection-socket conn))) | ||||||
|  |           #f | ||||||
|  |           (if (string-prefix? "/" dir) | ||||||
|  |               (cons "/" components) | ||||||
|  |               components)))) | ||||||
| 
 | 
 | ||||||
| (define (ftp-size conn file) | (define (ftp-size conn file) | ||||||
|   "Return the size in bytes of FILE." |   "Return the size in bytes of FILE." | ||||||
|  |  | ||||||
		Reference in a new issue