aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nar-herder/recent-changes.scm32
1 files changed, 19 insertions, 13 deletions
diff --git a/nar-herder/recent-changes.scm b/nar-herder/recent-changes.scm
index e4fe7d1..26d1027 100644
--- a/nar-herder/recent-changes.scm
+++ b/nar-herder/recent-changes.scm
@@ -137,26 +137,32 @@
(log-msg 'ERROR "exception in recent change listener " exn)
#f)
(lambda ()
- (let ((recent-changes
- (database-select-recent-changes database after)))
-
- (metric-increment recent-changes-count-metric
- #:by (length recent-changes))
-
- (for-each
- (lambda (change-details)
- (when (not (member change-details
- last-processed-recent-changes))
+ (let* ((recent-changes
+ (database-select-recent-changes database after))
+ (unprocessed-recent-changes
+ (remove
+ (lambda (change-details)
+ (member change-details last-processed-recent-changes))
+ recent-changes)))
+
+ (unless (null? unprocessed-recent-changes)
+ (metric-increment recent-changes-count-metric
+ #:by (length unprocessed-recent-changes))
+
+ (for-each
+ (lambda (change-details)
(let ((change (assq-ref change-details 'change)))
(cond
((string=? change "addition")
(process-addition-change change-details))
((string=? change "removal")
(process-removal-change change-details))
- (else #f)))))
- recent-changes)
+ (else #f))))
+ unprocessed-recent-changes))
- recent-changes))
+ ;; Use the unprocessed recent changes here to carry
+ ;; forward all processed changes to the next pass
+ unprocessed-recent-changes))
#:unwind? #t)
(#f (loop after '()))
(recent-changes