git-download: 'git-predicate' now ignores deleted files.

When git-predicate is used on an active worktree, some files in the
index might not exist on the filesystem.  Instead of failing with "No
such file or directory", these should be ignored.

* guix/git-download.scm (git-predicate): Wrap 'lstat' call in
'false-if-exception'.  Return RESULT when STAT is #f.

Co-authored-by: Andrew Whatson <whatson@gmail.com>
This commit is contained in:
Ludovic Courtès 2021-05-28 11:02:07 +02:00
parent 681af1fb78
commit 50d5bb1f3e
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 7 additions and 5 deletions

View File

@ -231,11 +231,13 @@ absolute file name and STAT is the result of 'lstat'."
(lambda ()
(let* ((files (git-file-list directory))
(inodes (fold (lambda (file result)
(let ((stat
(lstat (string-append directory "/"
file))))
(vhash-consv (stat:ino stat) (stat:dev stat)
result)))
(let* ((file (string-append directory "/" file))
(stat (false-if-exception (lstat file))))
;; Ignore FILE if it has been deleted.
(if stat
(vhash-consv (stat:ino stat) (stat:dev stat)
result)
result)))
vlist-null
files)))
(lambda (file stat)