From 57ef6c60951aee21943e61ccf9b7d5976b2ffb30 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sun, 20 Mar 2011 00:29:27 +0100 Subject: Improve status output and don't download when we already have the file --- henrietta-cache.scm | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/henrietta-cache.scm b/henrietta-cache.scm index e8beb01..1e04b92 100644 --- a/henrietta-cache.scm +++ b/henrietta-cache.scm @@ -49,18 +49,22 @@ EOF (uri-template (cadr uri-info))) (for-each (lambda (egg-release) - (let* ((patterns `((egg-name . ,egg-name) - (egg-release . ,egg-release) - (chicken-release . ,*chicken-release*))) - (uri (replace-uri-patterns uri-template patterns))) - (printf "Downloading egg ~A, release ~A from ~A...\n" - egg-name egg-release uri) - ;; Here we should dispatch on type to determine what to do! - (call-with-input-request - uri #f (lambda (i) - (call-with-output-file - (make-pathname egg-cache-dir egg-release) - (lambda (o) (copy-port i o))))))) + (let ((cached-file (make-pathname egg-cache-dir + egg-release + (->string type)))) + (unless (file-exists? cached-file) + (let* ((patterns `((egg-name . ,egg-name) + (egg-release . ,egg-release) + (chicken-release . ,*chicken-release*))) + (uri (replace-uri-patterns uri-template patterns))) + (printf "\tDownloading release ~A from ~A\n" + egg-release uri) + ;; Here we should dispatch on type to determine what to do! + (call-with-input-request + uri #f (lambda (i) + (call-with-output-file + cached-file + (lambda (o) (copy-port i o))))))))) (cdr uri/releases)))) uris/releases))) @@ -75,6 +79,7 @@ EOF (patterns `((egg-name . ,egg-name) (chicken-release . ,*chicken-release*))) (uri (replace-uri-patterns egg-uri-template patterns))) + (printf "Caching egg '~A'\n" egg-name) (let collect-releases ((info (with-input-from-request uri #f read-file)) (uris/releases '()) (uris '())) -- cgit v1.2.3