diff mbox series

[bug#50960,v2,10/11] cache: Gracefully handle non-existent cache.

Message ID 20211011213809.17482-11-ludo@gnu.org
State New
Headers show
Series 'guix shell' strikes again | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Oct. 11, 2021, 9:38 p.m. UTC
* guix/cache.scm (maybe-remove-expired-cache-entries): Ignore ENOENT
when writing EXPIRY-FILE.
---
 guix/cache.scm | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/guix/cache.scm b/guix/cache.scm
index 0401a9d428..51009809bd 100644
--- a/guix/cache.scm
+++ b/guix/cache.scm
@@ -101,7 +101,13 @@  (define last-expiry-date
                                   #:now now
                                   #:entry-expiration entry-expiration
                                   #:delete-entry delete-entry)
-    (call-with-output-file expiry-file
-      (cute write (time-second now) <>))))
+    (catch 'system-error
+      (lambda ()
+        (call-with-output-file expiry-file
+          (cute write (time-second now) <>)))
+      (lambda args
+        ;; ENOENT means CACHE does not exist.
+        (unless (= ENOENT (system-error-errno args))
+          (apply throw args))))))
 
 ;;; cache.scm ends here