[PATCH himitsu] himitsud: query: close prompter if decrypt but no matches
Export this patch
---
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.
--
2.41.0