+sub ipc_atfork_child {
+ my ($self) = @_;
+ my $lei = $self->{lei};
+ $lei->lei_atfork_child(1) if $lei;
+ $self->SUPER::ipc_atfork_child;
+}
+
+sub refresh_local_externals {
+ my ($self) = @_;
+ my $cfg = $self->{lei}->_lei_cfg or return;
+ my $cur_cfg = $self->{cur_cfg} // -1;
+ my $lxs = $self->{lxs_all_local};
+ if ($cfg != $cur_cfg || !$lxs) {
+ $lxs = PublicInbox::LeiXSearch->new;
+ my @loc = $self->{lei}->externals_each;
+ for my $loc (@loc) { # locals only
+ $lxs->prepare_external($loc) if -d $loc;
+ }
+ $self->{lei}->ale->refresh_externals($lxs);
+ $lxs->{git} = $self->{lei}->ale->git;
+ $self->{lxs_all_local} = $lxs;
+ $self->{cur_cfg} = $cfg;
+ }
+}
+
+sub write_prepare {
+ my ($self, $lei) = @_;
+ unless ($self->{-ipc_req}) {
+ require PublicInbox::LeiXSearch;
+ $self->ipc_lock_init($lei->store_path . '/ipc.lock');
+ # Mail we import into lei are private, so headers filtered out
+ # by -mda for public mail are not appropriate
+ local @PublicInbox::MDA::BAD_HEADERS = ();
+ $self->ipc_worker_spawn('lei_store', $lei->oldset,
+ { lei => $lei });
+ }
+ my $wait = $self->ipc_do('refresh_local_externals');
+ $lei->{sto} = $self;
+}
+