From 935ef75d590c030fbec9d3f56091b07f3bf4880b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 1 May 2023 20:09:37 +0200 Subject: Support setting a storage limit with no nar removal criteria As a way of limiting the storage space used, but without removing any nars. While this will mean if you reduce the storage limit, no nars will be removed, I still think this is a useful way to run the nar-herder. --- scripts/nar-herder.in | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/nar-herder.in b/scripts/nar-herder.in index 9845e46..c4a4bd2 100644 --- a/scripts/nar-herder.in +++ b/scripts/nar-herder.in @@ -617,19 +617,22 @@ metrics-registry)))) - (when (and (assq-ref opts 'storage) - (number? (assq-ref opts 'storage-limit))) - (start-nar-removal-thread database - canonical-storage - (assq-ref opts 'storage-limit) - metrics-registry - (filter-map - (match-lambda - ((key . val) - (if (eq? key 'storage-nar-removal-criteria) - val - #f))) - opts))) + (let ((nar-removal-criteria + (filter-map + (match-lambda + ((key . val) + (if (eq? key 'storage-nar-removal-criteria) + val + #f))) + opts))) + (when (and (assq-ref opts 'storage) + (number? (assq-ref opts 'storage-limit)) + (not (null? nar-removal-criteria))) + (start-nar-removal-thread database + canonical-storage + (assq-ref opts 'storage-limit) + metrics-registry + nar-removal-criteria))) (log-msg 'INFO "starting server, listening on " (assq-ref opts 'host) ":" (assq-ref opts 'port)) -- cgit v1.2.3