diff options
author | Christopher Baines <mail@cbaines.net> | 2019-12-30 11:26:23 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-12-30 11:26:23 +0000 |
commit | 7881eec3152b19de1850c3ef54236f75ae5ed015 (patch) | |
tree | 3b48818ef2f38c4bfc96eb4e72fcdd7e06cd3d12 | |
parent | 57ee3c8988dfdad0b0a8c34335872d547d00a616 (diff) | |
download | data-service-7881eec3152b19de1850c3ef54236f75ae5ed015.tar data-service-7881eec3152b19de1850c3ef54236f75ae5ed015.tar.gz |
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.
-rw-r--r-- | guix-data-service/model/derivation.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm index 835a187..2122121 100644 --- a/guix-data-service/model/derivation.scm +++ b/guix-data-service/model/derivation.scm @@ -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) |