Peter Bex avatar Peter Bex committed d43f217

Add handling for meta-files

Comments (0)

Files changed (1)

henrietta-cache.scm

                                          (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))))
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.