Add a function to backfill missing derivation source file nars
If the file exists in the local store, then read it and add an entry to the derivation_source_file_nars table. This will help to fill in the missing entries, as currently entries are only added when the derivation source file isn't in the database when the load new revision job runs.
This commit is contained in:
parent
57ee3c8988
commit
7881eec315
1 changed files with 27 additions and 0 deletions
|
|
@ -1045,6 +1045,33 @@ INSERT INTO derivation_source_file_nars (
|
|||
(number->string uncompressed-size)
|
||||
(string-append "\\x" data-string))))))
|
||||
|
||||
(define (backfill-derivation-source-file-nars conn)
|
||||
(define (missing-batch)
|
||||
(exec-query
|
||||
conn
|
||||
"
|
||||
SELECT id, store_path
|
||||
FROM derivation_source_files
|
||||
WHERE id NOT IN (
|
||||
SELECT derivation_source_file_id FROM derivation_source_file_nars
|
||||
)
|
||||
LIMIT 1000"))
|
||||
|
||||
(let loop ((batch (missing-batch)))
|
||||
(unless (null? batch)
|
||||
(for-each
|
||||
(match-lambda
|
||||
((id source-file)
|
||||
(if (file-exists? source-file)
|
||||
(begin
|
||||
(insert-derivation-source-file-nar conn
|
||||
(string->number id)
|
||||
source-file)
|
||||
(simple-format #t "inserting ~A\n" source-file))
|
||||
(simple-format #t "missing ~A\n" source-file))))
|
||||
batch)
|
||||
(loop (missing-batch)))))
|
||||
|
||||
(define (insert-missing-derivations conn
|
||||
derivation-ids-hash-table
|
||||
derivations)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue