Subject: bug#76323: 30.0.93; auth-source-pass: Annoying error when ~/.password-store doesn't exist

From: "Basil L. Contovounesios" <[email-masked]>
Date: Sun, 16 Feb 2025 10:17:18 +0100

Naofumi Yasufuku [2025-02-16 14:30 +0900] wrote:

> @@ -236,9 +236,10 @@ auth-source-pass--do-debug
>  (defun auth-source-pass-entries ()
>    "Return a list of all password store entries."
>    (let ((store-dir (expand-file-name auth-source-pass-filename)))
> -    (mapcar
> -     (lambda (file) (file-name-sans-extension (file-relative-name file store-dir)))
> -     (directory-files-recursively store-dir "\\.gpg\\'"))))
> +    (when (file-directory-p store-dir)
> +      (mapcar
> +       (lambda (file) (file-name-sans-extension (file-relative-name file store-dir)))
> +       (directory-files-recursively store-dir "\\.gpg\\'")))))

Would it be any better to have the filesystem read and error check in a
single atomic step?  For example:

diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index b0b32ca263b..80e412e1697 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -243,7 +243,8 @@ auth-source-pass-entries
   (let ((store-dir (expand-file-name auth-source-pass-filename)))
     (mapcar
      (lambda (file) (file-name-sans-extension (file-relative-name file store-dir)))
-     (directory-files-recursively store-dir "\\.gpg\\'"))))
+     (ignore-error file-missing
+       (directory-files-recursively store-dir "\\.gpg\\'")))))
 
 (defun auth-source-pass--find-match (hosts user port)
   "Return password-store entry data matching HOSTS, USER and PORT.

Thanks,
-- 
Basil