From 104b4e25ab7da5697f2f6f1ddfdd4955f05afece Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 30 May 2022 15:07:14 +0200 Subject: cache: Catch invalid 'last-expiry-cleanup'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes . * guix/cache.scm (maybe-remove-expired-cache-entries)[last-expiry-date]: Use 'get-string-all' + 'string->number' instead of 'read'; ignore invalid numbers. * tests/cache.scm ("maybe-remove-expired-cache-entries, empty cache") ("maybe-remove-expired-cache-entries, corrupted cache"): New tests. Co-authored-by: Ludovic Courtès --- tests/cache.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/cache.scm b/tests/cache.scm index 80b44d69aa..d495ace2bd 100644 --- a/tests/cache.scm +++ b/tests/cache.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017, 2020 Ludovic Courtès +;;; Copyright © 2022 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -74,6 +75,20 @@ (lambda (port) (display 0 port))))) +(test-equal "maybe-remove-expired-cache-entries, empty cache" + '("a" "b" "c") + (test-cache-cleanup cache + (call-with-output-file (string-append cache "/last-expiry-cleanup") + (lambda (port) + (display "" port))))) + +(test-equal "maybe-remove-expired-cache-entries, corrupted cache" + '("a" "b" "c") + (test-cache-cleanup cache + (call-with-output-file (string-append cache "/last-expiry-cleanup") + (lambda (port) + (display "1\"34657890" port))))) + (test-end "cache") ;;; Local Variables: -- cgit v1.2.3