git: Update the mtime of the just-updated checkout.

Reported by zimoun <zimon.toutoune@gmail.com>.

Previously, the mtime of CACHE-DIRECTORY may or may not have been
updated after a pull.  Thus, 'maybe-remove-expired-cache-entries' could
potentially delete CACHE-DIRECTORY right before it's returned.

* guix/git.scm (update-cached-checkout): Call 'utime' on CACHE-DIRECTORY.
This commit is contained in:
Ludovic Courtès 2021-06-11 23:32:45 +02:00
parent 6a9abdcd5d
commit baf0a42882
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 8 additions and 0 deletions

View File

@ -424,6 +424,14 @@ it unchanged."
;; REPOSITORY as soon as possible.
(repository-close! repository)
;; Update CACHE-DIRECTORY's mtime to so the cache logic sees it.
(match (gettimeofday)
((seconds . microseconds)
(let ((nanoseconds (* 1000 microseconds)))
(utime cache-directory
seconds seconds
nanoseconds nanoseconds))))
;; When CACHE-DIRECTORY is a sub-directory of the default cache
;; directory, remove expired checkouts that are next to it.
(let ((parent (dirname cache-directory)))