From 24ffacf4b7df4f572a4c51ca6d87d120d24a17d2 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Sun, 20 Mar 2011 20:09:33 +0100 Subject: Add handling for meta-files --- henrietta-cache.scm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/henrietta-cache.scm b/henrietta-cache.scm index 05d1925..affbb02 100644 --- a/henrietta-cache.scm +++ b/henrietta-cache.scm @@ -78,7 +78,33 @@ EOF (make-pathname tmpdir (car contents)) tmpdir))) (rename-file contents-dir cache-dir) - (system (sprintf "rm -rf ~A" (qs tmpdir))))))))) + (system (sprintf "rm -rf ~A" (qs tmpdir))))))) + (meta-file . ,(lambda (uri cache-dir) + (let* ((meta (car (call-with-input-request uri #f read-file))) + (uri (uri-reference uri)) + (add-to-uri + (lambda (f) + (let ((rel (update-uri (uri-reference "") + path: (string-split f "/")))) + (uri-relative-to rel uri)))) + (files (alist-ref 'files meta))) + (unless files + (error "No \"files\" entry found in meta file" uri)) + (for-each + (lambda (file) + (printf "\t\t~A...\n" file) + (flush-output) + (and-let* ((dirname (pathname-directory file)) + (directory (make-pathname cache-dir dirname))) + (unless (file-exists? directory) + (create-directory directory #t))) + (call-with-input-request + (add-to-uri file) #f + (lambda (i) + (call-with-output-file + (make-pathname cache-dir file) + (lambda (o) (copy-port i o)))))) + files)))))) (define (download-all-release-files egg-name uris/releases uris) (let ((egg-cache-dir (make-pathname *cache-directory* (->string egg-name)))) -- cgit v1.2.3