From eb83cceb7eb2774e9d7ff90317ab1d0dcf350f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 17 Oct 2025 15:34:03 +0200 Subject: [PATCH] =?UTF-8?q?shell:=20Don=E2=80=99t=20rely=20on=20atime=20fo?= =?UTF-8?q?r=20caching.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relying on atime was fine even on ‘noatime’ file systems because the atime was explicitly updated. However, on file systems with atime enabled, cache items were potentially retained for too long since scanning the cache directory could update atimes. * guix/scripts/shell.scm (options-with-caching): In ‘utime’ call, change both the mtime and the atime. (guix-shell)[entry-expiration]: Use ‘file-expiration-time’ with ‘stat:mtime’. Change-Id: Ibe2aedae41a1018a95c2efe7f2dcf08bd1caae2a --- guix/scripts/shell.scm | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/guix/scripts/shell.scm b/guix/scripts/shell.scm index 80251606a321d5140a101c345a890ecfeed5d8a9..541c8a3184a8b9c4485385359da59f4b08e4de58 100644 --- a/guix/scripts/shell.scm +++ b/guix/scripts/shell.scm @@ -250,10 +250,8 @@ cache) or a 'gc-root' key (to add the profile to cache)." stat (<= timestamp (stat:mtime stat))) (let ((now (current-time))) - ;; Update the atime on ROOT to reflect usage. - (utime root - now (stat:mtime stat) 0 (stat:mtimensec stat) - AT_SYMLINK_NOFOLLOW) + ;; Update the mtime on ROOT to reflect usage. + (utime root now now 0 0 AT_SYMLINK_NOFOLLOW) (alist-cons 'profile root (remove (match-lambda (('load . _) #t) @@ -566,11 +564,9 @@ concatenates MANIFESTS, a list of expressions." (file (string-append directory "/" file))) (or (scandir directory) '()))) - (define* (entry-expiration file) + (define entry-expiration ;; Return the time at which FILE, a cached profile, is considered expired. - (match (false-if-exception (lstat file)) - (#f 0) ;FILE may have been deleted in the meantime - (st (+ (stat:atime st) (* 60 60 24 7))))) + (file-expiration-time (* 60 60 24 7) stat:mtime)) (define opts (parse-args args))