diff options
author | Christopher Baines <mail@cbaines.net> | 2021-04-10 08:30:48 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-04-10 08:30:48 +0100 |
commit | 28a7cb6291af4eae4e53b2aac5dba387eef771da (patch) | |
tree | 14f391335b1334fbb96b738e21dfc8c83db9016a /guix-data-service | |
parent | 91aebb3c4eaa026f2bf50cca04aa9e04c654bad4 (diff) | |
download | data-service-28a7cb6291af4eae4e53b2aac5dba387eef771da.tar data-service-28a7cb6291af4eae4e53b2aac5dba387eef771da.tar.gz |
Better handle filtering narinfos
This avoids a query error when trying to insert data for 0 narinfos.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/substitutes.scm | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/guix-data-service/substitutes.scm b/guix-data-service/substitutes.scm index 4375a09..eff5208 100644 --- a/guix-data-service/substitutes.scm +++ b/guix-data-service/substitutes.scm @@ -80,22 +80,25 @@ (simple-format #t "Got ~A narinfo files\n" (length narinfos)) - (unless (eq? (length narinfos) 0) - (with-postgresql-transaction - conn - (lambda (conn) - (record-narinfo-details-and-return-ids - conn - build-server-id - (filter-map - (lambda (narinfo) - (if (> (narinfo-size narinfo) - %narinfo-max-size) - (begin - (simple-format (current-error-port) - "narinfo ~A has excessive size ~A\n" - (narinfo-path narinfo) - (narinfo-size narinfo)) - #f) - narinfo)) - narinfos))))))) + (let ((filtered-narinfos + (filter-map + (lambda (narinfo) + (if (> (narinfo-size narinfo) + %narinfo-max-size) + (begin + (simple-format (current-error-port) + "narinfo ~A has excessive size ~A\n" + (narinfo-path narinfo) + (narinfo-size narinfo)) + #f) + narinfo)) + narinfos))) + + (unless (null? filtered-narinfos) + (with-postgresql-transaction + conn + (lambda (conn) + (record-narinfo-details-and-return-ids + conn + build-server-id + filtered-narinfos))))))) |