guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#77680] [PATCH 3/4] substitutes: Ignore corrupt cached narinfos.


From: Christopher Baines
Subject: [bug#77680] [PATCH 3/4] substitutes: Ignore corrupt cached narinfos.
Date: Thu, 10 Apr 2025 11:31:27 +0100
User-agent: mu4e 1.12.9; emacs 29.4

Ludovic Courtès <ludo@gnu.org> writes:

> * guix/substitutes.scm (cached-narinfo): Wrap ‘read’ call in
> ‘false-if-exception’.  Add catch-all ‘match’ clause.
>
> Change-Id: I2d776f64b6521f778b4ab3f956b35cdef2ddb383
> ---
>  guix/substitutes.scm | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/guix/substitutes.scm b/guix/substitutes.scm
> index 86b9f5472a..45c165e03e 100644
> --- a/guix/substitutes.scm
> +++ b/guix/substitutes.scm
> @@ -300,7 +300,7 @@ (define (cached-narinfo cache-url path)
>      (lambda ()
>        (call-with-input-file cache-file
>          (lambda (p)
> -          (match (read p)
> +          (match (false-if-exception (read p))
>              (('narinfo ('version 2)
>                         ('cache-uri cache-uri)
>                         ('date date) ('ttl ttl) ('value #f))
> @@ -315,7 +315,8 @@ (define (cached-narinfo cache-url path)
>               (if (obsolete? date now ttl)
>                   (values #f #f)
>                   (values #t (string->narinfo value cache-uri))))
> -            (('narinfo ('version v) _ ...)
> +            (_
> +             ;; Corrupt or incompatible cached entry.
>               (values #f #f))))))
>      (lambda _
>        (values #f #f))))

I believe the particular failure case we're introducing here is that the
cache file is empty, so maybe we could match that specific case here and
handle it silently.

I'm a bit wary of handling any and all cache issues silently since that
could make it harder to spot that the caching is entirely broken.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]