diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-06-08 14:53:16 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-06-08 14:53:16 +0200 |
commit | 091eb323ba2787ce64a1fb2796e7e06dbee6037c (patch) | |
tree | 446a869245541bd48f303caef76e4c24f6e7d0bb /guix/cache.scm | |
parent | 05fef7bfc60058763f5a64ec0feaf3876b56281d (diff) | |
parent | 0c5299200ffcd16370f047b7ccb187c60f30da34 (diff) |
Merge branch 'master' into staging
Diffstat (limited to 'guix/cache.scm')
-rw-r--r-- | guix/cache.scm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/guix/cache.scm b/guix/cache.scm index 51009809bd..be0de90e67 100644 --- a/guix/cache.scm +++ b/guix/cache.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2020, 2021 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2022 Simon Tournier <zimon.toutoune@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,9 +18,11 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (guix cache) + #:use-module ((guix utils) #:select (with-atomic-file-output)) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) #:use-module (ice-9 match) + #:use-module ((ice-9 textual-ports) #:select (get-string-all)) #:export (obsolete? delete-file* file-expiration-time @@ -93,7 +96,9 @@ CLEANUP-PERIOD denotes the minimum time between two cache cleanups." (define last-expiry-date (catch 'system-error (lambda () - (call-with-input-file expiry-file read)) + (or (string->number + (call-with-input-file expiry-file get-string-all)) + 0)) (const 0))) (when (obsolete? last-expiry-date now cleanup-period) @@ -103,7 +108,7 @@ CLEANUP-PERIOD denotes the minimum time between two cache cleanups." #:delete-entry delete-entry) (catch 'system-error (lambda () - (call-with-output-file expiry-file + (with-atomic-file-output expiry-file (cute write (time-second now) <>))) (lambda args ;; ENOENT means CACHE does not exist. |