Peter Bex avatar Peter Bex committed 580e5c5

Improve status output and don't download when we already have the file

Comments (0)

Files changed (1)

henrietta-cache.scm

                            (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)))
 
             (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 '()))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.