raco setup: create docindex database before trying to read

Commit 0f80c71fab propagates read-only mode so that a documentation
database is not created for read operations, but `raco setup` (with
documentation-index support) attempts to read the database before
writing to it. Change `raco setup` to make sure the database
exists if a later write operation is expected to create it.

Merge bug fix to v6.0 (pending review)
This commit is contained in:
Matthew Flatt 2013-12-16 18:19:48 -07:00
parent ac480e7535
commit 6ff7359212

View File

@ -223,6 +223,20 @@
(define main-doc-exists? (ormap (lambda (d) (member 'main-doc-root (doc-flags d))) (define main-doc-exists? (ormap (lambda (d) (member 'main-doc-root (doc-flags d)))
main-docs)) main-docs))
(define (can-build*? docs) (can-build? only-dirs docs))
(define main-db (find-doc-db-path latex-dest #f main-doc-exists?))
(define user-db (find-doc-db-path latex-dest #t main-doc-exists?))
;; Ensure that databases are created:
(define (touch-db db-file)
(doc-db-disconnect
(doc-db-file->connection db-file #t)))
(when (ormap can-build*? main-docs)
(touch-db main-db))
(when (ormap can-build*? user-docs)
(touch-db user-db))
(when (and (or (not only-dirs) tidy?) (when (and (or (not only-dirs) tidy?)
(not avoid-main?) (not avoid-main?)
(not latex-dest)) (not latex-dest))
@ -256,7 +270,6 @@
ht ht
setup-printf))))) setup-printf)))))
(define (can-build*? docs) (can-build? only-dirs docs))
(define auto-main? (and auto-start-doc? (define auto-main? (and auto-start-doc?
(or (ormap can-build*? main-docs) (or (ormap can-build*? main-docs)
(and tidy? (not avoid-main?))))) (and tidy? (not avoid-main?)))))
@ -399,9 +412,6 @@
(get-files! #f) (get-files! #f)
(doc-db-clean-files user-db files)))) (doc-db-clean-files user-db files))))
(define main-db (find-doc-db-path latex-dest #f main-doc-exists?))
(define user-db (find-doc-db-path latex-dest #t main-doc-exists?))
(define (make-loop first? iter) (define (make-loop first? iter)
(let ([infos (filter-not info-failed? infos)] (let ([infos (filter-not info-failed? infos)]
[src->info (make-hash)] [src->info (make-hash)]