raco pkg update: check already installed, first, in given scope

Before consulting a catalog, etc., check whether a given package name
is currently installed. The new check applies only if a scope is
specified, since scope inference implies the check already.
This commit is contained in:
Matthew Flatt 2015-05-16 15:48:01 -06:00
parent 12308e3f17
commit aaef69f40a

View File

@ -1177,7 +1177,10 @@
(define all-mode? (and all? (empty? in-pkgs)))
(define pkgs (cond
[all-mode? (hash-keys db)]
[else in-pkgs]))
[else
(unless skip-uninstalled?
(ensure-installed in-pkgs db))
in-pkgs]))
(define update-cache (make-hash))
(define catalog-lookup-cache (make-hash))
(define remote-checksum-cache (make-hash))
@ -1278,6 +1281,18 @@
;; ----------------------------------------
(define (ensure-installed in-pkgs db)
(for ([d (in-list in-pkgs)])
(define name
(if (pkg-desc? d)
(or (pkg-desc-name d)
(package-source->name (pkg-desc-source d)
(pkg-desc-type d)))
(package-source->name d)))
(void (package-info name #:db db))))
;; ----------------------------------------
(define (clear-checksums-in-cache! update-cache)
(define l (for/list ([(k v) (in-hash update-cache)]
#:when (string? v))