pkg catalog-update: install updates as a single transaction

Relevant to PR 14848
This commit is contained in:
Matthew Flatt 2014-11-26 06:46:31 -07:00
parent 596a4f655c
commit dd02cf8952

View File

@ -40,6 +40,8 @@
(parameterize ([current-pkg-catalogs (list (string->url catalog))]) (parameterize ([current-pkg-catalogs (list (string->url catalog))])
(define details (for/hash ([(name ht) (get-all-pkg-details-from-catalogs)]) (define details (for/hash ([(name ht) (get-all-pkg-details-from-catalogs)])
(values name (select-info-version ht)))) (values name (select-info-version ht))))
(db:call-with-pkgs-transaction
(lambda ()
;; set packages: ;; set packages:
(db:set-pkgs! catalog (for/list ([(name ht) (in-hash details)]) (db:set-pkgs! catalog (for/list ([(name ht) (in-hash details)])
(db:pkg name (db:pkg name
@ -59,7 +61,7 @@
(db:set-pkg-tags! name catalog tags)) (db:set-pkg-tags! name catalog tags))
(define deps (hash-ref ht 'dependencies #f)) (define deps (hash-ref ht 'dependencies #f))
(when deps (when deps
(db:set-pkg-dependencies! name catalog checksum deps))) (db:set-pkg-dependencies! name catalog checksum deps)))))
(when consult-packages? (when consult-packages?
;; If module information isn't available for a package, download ;; If module information isn't available for a package, download
;; the package to fill in that information: ;; the package to fill in that information:
@ -76,6 +78,7 @@
name name
(hash-ref ht 'checksum #f) (hash-ref ht 'checksum #f)
#f))) #f)))
(db:call-with-pkgs-transaction
(lambda ()
(db:set-pkg-modules! name catalog checksum modules) (db:set-pkg-modules! name catalog checksum modules)
(db:set-pkg-dependencies! name catalog checksum deps))))))) (db:set-pkg-dependencies! name catalog checksum deps)))))))))