From c0a51b7fd8556d40617d772e5fc8872193f9423b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 17 Dec 2020 01:04:58 +0000 Subject: Use the same skip if narinfo exists logic in the publish hook As is used in the S3 publish hook. This is useful when you don't want to overwrite existing nar+narinfo entries. --- guix-build-coordinator/hooks.scm | 47 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'guix-build-coordinator/hooks.scm') diff --git a/guix-build-coordinator/hooks.scm b/guix-build-coordinator/hooks.scm index b09cefe..97f3311 100644 --- a/guix-build-coordinator/hooks.scm +++ b/guix-build-coordinator/hooks.scm @@ -111,29 +111,30 @@ (string-append publish-directory "/" narinfo-filename))) - (copy-file nar-location nar-destination) - - (call-with-output-file narinfo-location - (lambda (port) - (display (narinfo-string - output-filename - (assq-ref output 'hash) - (assq-ref output 'size) - (vector->list - (assq-ref output 'references)) - `((lzip ,(stat:size (stat nar-location #f)))) - #:system (datastore-find-derivation-system - datastore - derivation-name) - #:derivation derivation-name - #:public-key public-key - #:private-key private-key) - port))) - - (when post-publish-hook - (post-publish-hook publish-directory - narinfo-filename - nar-filename)))) + (unless (file-exists? narinfo-location) + (copy-file nar-location nar-destination) + + (call-with-output-file narinfo-location + (lambda (port) + (display (narinfo-string + output-filename + (assq-ref output 'hash) + (assq-ref output 'size) + (vector->list + (assq-ref output 'references)) + `((lzip ,(stat:size (stat nar-location #f)))) + #:system (datastore-find-derivation-system + datastore + derivation-name) + #:derivation derivation-name + #:public-key public-key + #:private-key private-key) + port))) + + (when post-publish-hook + (post-publish-hook publish-directory + narinfo-filename + nar-filename))))) (datastore-list-build-outputs datastore build-id))))) (define* (build-success-s3-publish-hook -- cgit v1.2.3