Rework insert-derivation-sources to use a helper function
This means it returns ids properly.
This commit is contained in:
parent
d15ba4f25c
commit
7e7cc1c8f1
1 changed files with 6 additions and 44 deletions
|
|
@ -974,18 +974,6 @@ WHERE derivation_source_files.store_path = $1"
|
||||||
");"))
|
");"))
|
||||||
|
|
||||||
(define (insert-derivation-sources conn derivation-id sources)
|
(define (insert-derivation-sources conn derivation-id sources)
|
||||||
(define (insert-into-derivation-source-files store-paths)
|
|
||||||
(string-append
|
|
||||||
"INSERT INTO derivation_source_files (store_path) VALUES "
|
|
||||||
(string-join
|
|
||||||
(map (lambda (store-path)
|
|
||||||
(simple-format
|
|
||||||
#f "('~A')" store-path))
|
|
||||||
store-paths)
|
|
||||||
",")
|
|
||||||
" RETURNING id"
|
|
||||||
";"))
|
|
||||||
|
|
||||||
(define (insert-into-derivation-sources derivation-source-file-ids)
|
(define (insert-into-derivation-sources derivation-source-file-ids)
|
||||||
(string-append
|
(string-append
|
||||||
"INSERT INTO derivation_sources "
|
"INSERT INTO derivation_sources "
|
||||||
|
|
@ -998,38 +986,12 @@ WHERE derivation_source_files.store_path = $1"
|
||||||
",")
|
",")
|
||||||
";"))
|
";"))
|
||||||
|
|
||||||
(let* ((existing-derivation-store-paths
|
(let ((sources-ids
|
||||||
(exec-query->vhash
|
(insert-missing-data-and-return-all-ids
|
||||||
conn
|
conn
|
||||||
(select-from-derivation-source-files sources)
|
"derivation_source_files"
|
||||||
second ;; store_path
|
'(store_path)
|
||||||
first)) ;; id
|
(map list sources))))
|
||||||
|
|
||||||
(missing-entries (filter
|
|
||||||
(lambda (store-path)
|
|
||||||
(not (vhash-assoc store-path
|
|
||||||
existing-derivation-store-paths)))
|
|
||||||
sources))
|
|
||||||
|
|
||||||
(new-derivation-source-file-entries
|
|
||||||
(if (null? missing-entries)
|
|
||||||
'()
|
|
||||||
(exec-query conn
|
|
||||||
(insert-into-derivation-source-files missing-entries))))
|
|
||||||
|
|
||||||
(new-entries-id-lookup-vhash
|
|
||||||
(two-lists->vhash missing-entries
|
|
||||||
new-derivation-source-file-entries))
|
|
||||||
|
|
||||||
(sources-ids
|
|
||||||
(map (lambda (store-path)
|
|
||||||
(cdr
|
|
||||||
(or (vhash-assoc store-path
|
|
||||||
existing-derivation-store-paths)
|
|
||||||
(vhash-assoc store-path
|
|
||||||
new-entries-id-lookup-vhash)
|
|
||||||
(error "missing derivation source files entry"))))
|
|
||||||
sources)))
|
|
||||||
|
|
||||||
(exec-query conn
|
(exec-query conn
|
||||||
(insert-into-derivation-sources sources-ids))
|
(insert-into-derivation-sources sources-ids))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue