my $oid = $req->{oid};
my $xibx = $req->{ibx};
my $eml = $req->{eml};
+ my $eidx_key = $xibx->eidx_key;
if (my $new_smsg = $req->{new_smsg}) { # 'm' on cross-posted message
my $xnum = $req->{xnum};
- $self->{oidx}->add_xref3($docid, $xnum, $oid, $xibx->eidx_key);
+ $self->{oidx}->add_xref3($docid, $xnum, $oid, $eidx_key);
$idx->shard_add_eidx_info($docid, $oid, $xibx, $eml);
check_batch_limit($req);
} else { # 'd'
- $self->{oidx}->remove_xref3($docid, $oid, $xibx->eidx_key);
- $idx->shard_remove_eidx_info($docid, $oid, $xibx, $eml);
+ my $rm_eidx_info;
+ my $nr = $self->{oidx}->remove_xref3($docid, $oid, $eidx_key,
+ \$rm_eidx_info);
+ if ($nr == 0) {
+ $idx->shard_remove($oid, $docid);
+ } elsif ($rm_eidx_info) {
+ $idx->shard_remove_eidx_info($docid, $oid, $xibx, $eml);
+ }
}
}
warn "E: $ekey unsupported inbox version (v$v)\n";
return;
}
- unless ($sync->{quit}) {
- index_todo($self, $sync, $_) for @{delete($sync->{todo}) // []};
- $self->{midx}->index_ibx($ibx) unless $sync->{quit};
+ for my $unit (@{delete($sync->{todo}) // []}) {
+ last if $sync->{quit};
+ index_todo($self, $sync, $unit);
}
+ $self->{midx}->index_ibx($ibx) unless $sync->{quit};
$ibx->git->cleanup; # done with this inbox, now
}
-regen_fmt => "%u/?\n",
};
local $SIG{USR1} = sub { $need_checkpoint = 1 };
- my $quit = sub { $sync->{quit} = 1; warn "gracefully quitting\n"; };
+ my $quit = PublicInbox::SearchIdx::quit_cb($sync);
local $SIG{QUIT} = $quit;
local $SIG{INT} = $quit;
local $SIG{TERM} = $quit;
# don't use $_ here, it'll get clobbered by reindex_checkpoint
for my $ibx (@{$self->{ibx_list}}) {
- _sync_inbox($self, $sync, $ibx);
last if $sync->{quit};
+ _sync_inbox($self, $sync, $ibx);
}
-
$self->{oidx}->rethread_done($opt) unless $sync->{quit};
PublicInbox::V2Writable::done($self);
my $info_dir = "$ALL/objects/info";
my $alt = "$info_dir/alternates";
my $mode = 0644;
- my (%old, @old, %new, @new);
+ my (@old, @new, %seen); # seen: st_dev + st_ino
if (-e $alt) {
open(my $fh, '<', $alt) or die "open $alt: $!";
$mode = (stat($fh))[2] & 07777;
- while (<$fh>) {
- push @old, $_ if !$old{$_}++;
+ while (my $line = <$fh>) {
+ chomp(my $d = $line);
+ if (my @st = stat($d)) {
+ next if $seen{"$st[0]\0$st[1]"}++;
+ } else {
+ warn "W: stat($d) failed (from $alt): $!\n";
+ }
+ push @old, $line;
}
}
for my $ibx (@{$self->{ibx_list}}) {
my $line = $ibx->git->{git_dir} . "/objects\n";
- next if $old{$line};
- $new{$line} = 1;
+ chomp(my $d = $line);
+ if (my @st = stat($d)) {
+ next if $seen{"$st[0]\0$st[1]"}++;
+ } else {
+ warn "W: stat($d) failed (from $ibx->{inboxdir}): $!\n";
+ }
push @new, $line;
}
if (scalar @new) {