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

Previous Next

Package: emacs;

Reported by: Naofumi Yasufuku <naofumi <at> yasufuku.dev>

Date: Sun, 16 Feb 2025 05:31:02 UTC

Severity: minor

Found in version 30.0.93

Full log


Message #8 received at 76323 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: Naofumi Yasufuku <naofumi <at> yasufuku.dev>
Cc: 76323 <at> debbugs.gnu.org
Subject: Re: bug#76323: 30.0.93; auth-source-pass: Annoying error when
 ~/.password-store doesn't exist
Date: Sun, 16 Feb 2025 10:17:18 +0100
[Message part 1 (text/plain, inline)]
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:

[file-missing.diff (text/x-diff, inline)]
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.
[Message part 3 (text/plain, inline)]
Thanks,
-- 
Basil

This bug report was last modified 95 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.