[PATCH consfigurator] GPG: handle missing file separately to subprocess errors

Sean Whitton spwhitton at spwhitton.name
Tue Oct 4 23:15:59 BST 2022


Hello,

On Tue 04 Oct 2022 at 11:00PM +02, Russell Sim wrote:

> When the gpg data source is missing explicitly signal a
> MISSING-DATA-SOURCE condition before calling subpocesses.  This makes
> the API more consistent with the other data sources.
>
> Signed-off-by: Russell Sim <rsl at simopolis.xyz>
> ---
>  src/data/util.lisp  | 7 +++----
>  tests/data/pgp.lisp | 6 ++++++
>  2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/data/util.lisp b/src/data/util.lisp
> index aa0451f..ef6cb2c 100644
> --- a/src/data/util.lisp
> +++ b/src/data/util.lisp
> @@ -57,8 +57,7 @@ as a string."
>  (defun gpg-file-as-string (location)
>    "Decrypt the contents of a gpg encrypted file at LOCATION, return as a
>  string."
> -  (handler-case
> +  (if (file-exists-p location)
>        (gpg (list "--decrypt" (unix-namestring location)))
> -    (subprocess-error (error)
> -      (missing-data-source "While attempt to decrypt ~A, gpg exited with ~A"
> -			   location (uiop:subprocess-error-code error)))))
> +      (missing-data-source "File not found while attempting to decrypt ~A"
> +                           location)))

Can you just confirm that if gpg exits nonzero for some other reason,
this still results in an error condition reaching the top level?

-- 
Sean Whitton



More information about the sgo-software-discuss mailing list