diff --git a/guix/git.scm b/guix/git.scm index ebe2600209..ed3fa56bc8 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -405,7 +405,16 @@ (define cached-checkout-expiration ;; Use the mtime rather than the atime to cope with file systems mounted ;; with 'noatime'. - (file-expiration-time (* 90 24 3600) stat:mtime)) + (let ((ttl (* 90 24 3600)) + (max-checkout-retention (* 9 30 24 3600))) + (lambda (file) + (match (false-if-exception (lstat file)) + (#f 0) ;FILE may have been deleted in the meantime + (st (min (pk 'ttl (+ (stat:mtime st) ttl)) + (pk 'maxttl (match (false-if-exception + (lstat (in-vicinity file ".git/config"))) + (#f +inf.0) + (st (+ (stat:mtime st) max-checkout-retention)))))))))) (define %checkout-cache-cleanup-period ;; Period for the removal of expired cached checkouts.