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,26 +40,28 @@
(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))))
;; set packages: (db:call-with-pkgs-transaction
(db:set-pkgs! catalog (for/list ([(name ht) (in-hash details)]) (lambda ()
(db:pkg name ;; set packages:
catalog (db:set-pkgs! catalog (for/list ([(name ht) (in-hash details)])
(hash-ref ht 'author "") (db:pkg name
(hash-ref ht 'source "") catalog
(hash-ref ht 'checksum "") (hash-ref ht 'author "")
(hash-ref ht 'description "")))) (hash-ref ht 'source "")
;; Add available module and dependency info: (hash-ref ht 'checksum "")
(for/list ([(name ht) (in-hash details)]) (hash-ref ht 'description ""))))
(define checksum (hash-ref ht 'checksum "")) ;; Add available module and dependency info:
(define mods (hash-ref ht 'modules #f)) (for/list ([(name ht) (in-hash details)])
(when mods (define checksum (hash-ref ht 'checksum ""))
(db:set-pkg-modules! name catalog checksum mods)) (define mods (hash-ref ht 'modules #f))
(define tags (hash-ref ht 'tags #f)) (when mods
(when tags (db:set-pkg-modules! name catalog checksum mods))
(db:set-pkg-tags! name catalog tags)) (define tags (hash-ref ht 'tags #f))
(define deps (hash-ref ht 'dependencies #f)) (when tags
(when deps (db:set-pkg-tags! name catalog tags))
(db:set-pkg-dependencies! name catalog checksum deps))) (define deps (hash-ref ht 'dependencies #f))
(when 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:set-pkg-modules! name catalog checksum modules) (db:call-with-pkgs-transaction
(db:set-pkg-dependencies! name catalog checksum deps))))))) (lambda ()
(db:set-pkg-modules! name catalog checksum modules)
(db:set-pkg-dependencies! name catalog checksum deps)))))))))