~sircmpwn/himitsu-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH himitsu] himitsud: query: close prompter if decrypt but no matches

Details
Message ID
<20230624031835.6894-1-xdavidwuph@gmail.com>
DKIM signature
missing
Download raw message
Patch: +5 -2
---
 cmd/himitsud/cmd.ha | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cmd/himitsud/cmd.ha b/cmd/himitsud/cmd.ha
index ce17c7d..5aa5232 100644
--- a/cmd/himitsud/cmd.ha
+++ b/cmd/himitsud/cmd.ha
@@ -190,10 +190,11 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
			writefmt(client, "error Failed to unlock");
			return;
		};
		if (!decrypt) {
		if (decrypt) {
			prompter = new;
		} else {
			prompt::close(&new)?;
		};
		prompter = new;
	};

	const q = query::parse_items(cmd.args)?;
@@ -236,6 +237,8 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
			writefmt(client, "error User declined");
			return;
		};
	} else if (prompter is prompt::prompter) {
		prompt::close(&(prompter: prompt::prompter))?;
	};

	let buf = bufio::dynamic(io::mode::WRITE);
-- 
2.41.0
Details
Message ID
<ea87e34e-d57a-11ac-fc41-dc76a14af150@strohwolke.at>
In-Reply-To
<20230624031835.6894-1-xdavidwuph@gmail.com> (view parent)
DKIM signature
missing
Download raw message
> ---
>   cmd/himitsud/cmd.ha | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/cmd/himitsud/cmd.ha b/cmd/himitsud/cmd.ha
> index ce17c7d..5aa5232 100644
> --- a/cmd/himitsud/cmd.ha
> +++ b/cmd/himitsud/cmd.ha
> @@ -190,10 +190,11 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
>   			writefmt(client, "error Failed to unlock");
>   			return;
>   		};
> -		if (!decrypt) {
> +		if (decrypt) {
> +			prompter = new;
> +		} else {
>   			prompt::close(&new)?;
>   		};
> -		prompter = new;
>   	};
>   
>   	const q = query::parse_items(cmd.args)?;
> @@ -236,6 +237,8 @@ fn exec_query(serv: *server, client: *client, args: []str) (void | cmderror) = {
>   			writefmt(client, "error User declined");
>   			return;
>   		};
> +	} else if (prompter is prompt::prompter) {
> +		prompt::close(&(prompter: prompt::prompter))?;
>   	};
>   
>   	let buf = bufio::dynamic(io::mode::WRITE);

It would be safer to use a defer after defining prompter like:

defer if (prompter is prompt::prompter) promt::close...

This would make the code a little less complex.
Reply to thread Export thread (mbox)