From 8f7b2b24e36b306d543670b6a4d3310e5be2f944 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 6 Feb 2023 22:38:33 +0100 Subject: Add a flag to allow ensuring the references for a nar are present --- scripts/nar-herder.in | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 2f4d6d1..32b467d 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -114,7 +114,10 @@ (cons key value))) (or (assq-ref result 'tags) '())) - (alist-delete 'tags result)))))) + (alist-delete 'tags result)))) + (option '("ensure-references-exist") #f #f + (lambda (opt name _ result) + (alist-cons 'ensure-references-exist #t result))))) (define %import-options-defaults '()) @@ -316,6 +319,19 @@ ;; matter (read-narinfo port "https://narherderdummyvalue"))))) + + (when (assq-ref opts 'ensure-references-exist) + (for-each + (lambda (reference) + (unless (database-select-narinfo-by-hash + database + (string-take (basename narinfo-file) 32)) + (error + (simple-format (current-error-port) + "missing reference to ~A\n" + reference)))) + (narinfo-references narinfo))) + (database-insert-narinfo database narinfo -- cgit v1.2.3