raco pkg: improve Git repo-download caching

Drop the path and branch from a URL that references a Git
repository, so that a single download is used for multiple
packages in the same repo.
This commit is contained in:
Matthew Flatt 2015-10-01 22:04:24 -06:00
parent acac7092c5
commit 8c51d50cd2

View File

@ -27,12 +27,12 @@
rest] rest]
[_ rp]))) [_ rp])))
(define (do-cache-file file url checksum use-cache? download-printf download!) (define (do-cache-file file url key checksum use-cache? download-printf download!)
(cond (cond
[(and use-cache? checksum) [(and use-cache? checksum)
(cache-file file (cache-file file
#:exists-ok? #t #:exists-ok? #t
(list (url->string url) checksum) (list key checksum)
(get-download-cache-dir) (get-download-cache-dir)
download! download!
#:log-error-string (lambda (s) (log-pkg-error s)) #:log-error-string (lambda (s) (log-pkg-error s))
@ -76,7 +76,8 @@
" server response: ~a") " server response: ~a")
(url->string url) (url->string url)
(read-line (open-input-string reply-s)))))))))) (read-line (open-input-string reply-s))))))))))
(do-cache-file file url checksum use-cache? download-printf download!))) (do-cache-file file url (url->string url) checksum
use-cache? download-printf download!)))
(define (clean-cache pkg-url checksum) (define (clean-cache pkg-url checksum)
(when pkg-url (when pkg-url
@ -116,7 +117,8 @@
#:exists-ok? #t #:exists-ok? #t
(directory-list)))) (directory-list))))
(do-cache-file tmp.tgz url checksum use-cache? download-printf download!) (do-cache-file tmp.tgz url (vector transport host port repo) checksum
use-cache? download-printf download!)
(unless unpacked? (unless unpacked?
(untgz tmp.tgz #:dest dest-dir)) (untgz tmp.tgz #:dest dest-dir))