From: Lars Ingebrigtsen Date: Sun, 5 Dec 2021 01:13:00 +0000 (+0100) Subject: Make package-dir-info more resilient X-Git-Tag: emacs-29.0.90~3617^2~14 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f14a4c377dfa6602e9e159c806656137854a667b;p=emacs.git Make package-dir-info more resilient * lisp/emacs-lisp/package.el (package-dir-info): Check that the file exists before using it (bug#41489). --- diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 08dfe504d27..66bbd631a72 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1181,13 +1181,17 @@ The return result is a `package-desc'." info) (while files (with-temp-buffer - (insert-file-contents (pop files)) - ;; When we find the file with the data, - (when (setq info (ignore-errors (package-buffer-info))) - ;; stop looping, - (setq files nil) - ;; set the 'dir kind, - (setf (package-desc-kind info) 'dir)))) + (let ((file (pop files))) + ;; The file may be a link to a nonexistent file; e.g., a + ;; lock file. + (when (file-exists-p file) + (insert-file-contents file) + ;; When we find the file with the data, + (when (setq info (ignore-errors (package-buffer-info))) + ;; stop looping, + (setq files nil) + ;; set the 'dir kind, + (setf (package-desc-kind info) 'dir)))))) (unless info (error "No .el files with package headers in `%s'" default-directory)) ;; and return the info.