user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 10/9] lei_query: fix relative path handling on --stdin
  @ 2021-04-17 10:00  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2021-04-17 10:00 UTC (permalink / raw)
  To: meta

Since --stdin could be waiting on user keyboard input or
something else slow, we handle it in the event loop.  That
means other commands can change the working directory of
lei-daemon while a query is being trickled to us via stdin.

Rearranging query handling internals to delay opening the
--output destination in commit 26e0fe73de93f451 meant
another command could throw off our --output pathname if
it is relative.

Fixes: 26e0fe73de93f451 ("lei_query: rearrange internals to capture query early")
---
 lib/PublicInbox/LeiQuery.pm | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/PublicInbox/LeiQuery.pm b/lib/PublicInbox/LeiQuery.pm
index 7ddba4cf..385ba0a9 100644
--- a/lib/PublicInbox/LeiQuery.pm
+++ b/lib/PublicInbox/LeiQuery.pm
@@ -53,6 +53,9 @@ sub qstr_add { # PublicInbox::InputPipe::consume callback for --stdin
 	my ($self) = @_; # $_[1] = $rbuf
 	if (defined($_[1])) {
 		$_[1] eq '' and return eval {
+			if (my $dfd = $self->{3}) {
+				chdir($dfd) or return $self->fail("fchdir: $!");
+			}
 			$self->{mset_opt}->{q_raw} = $self->{mset_opt}->{qstr};
 			$self->{lse}->query_approxidate($self->{lse}->git,
 						$self->{mset_opt}->{qstr});

^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-04-17  2:24     [SQUASH] test_common: fix -C $DIR with TEST_RUN_MODE=0 Eric Wong
2021-04-17 10:00  7% ` [PATCH 10/9] lei_query: fix relative path handling on --stdin Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).