}
# cur_cmt may be undef for unindex_oid, set by V2Writable::index_todo
if (defined(my $cur_cmt = $req->{cur_cmt})) {
- ${$req->{latest_cmt}} = $cur_cmt;
+ $req->{self}->{latest_cmt} = $cur_cmt;
}
}
sub index_oid { # git->cat_async callback for 'm'
my ($bref, $oid, $type, $size, $req) = @_;
- my $self = $req->{self};
+ my $self = $req->{self} // die 'BUG: {self} missing';
local $self->{current_info} = "$self->{current_info} $oid";
return if is_bad_blob($oid, $type, $size, $req->{oid});
my $new_smsg = $req->{new_smsg} = bless {
$req->{xnum} = cur_ibx_xnum($req, $bref, $mismatch) // do {
warn "# deleted\n";
warn "# mismatch $_->{blob}\n" for @$mismatch;
- ${$req->{latest_cmt}} = $req->{cur_cmt} //
+ $self->{latest_cmt} = $req->{cur_cmt} //
die "BUG: {cur_cmt} unset ($oid)\n";
return;
};
local $self->{need_checkpoint} = 0;
local $self->{nrec};
local $self->{-opt} = $opt;
+ local $self->{latest_cmt};
my $sync = { self => $self };
$self->idx_init($opt); # acquire lock via V2Writable::_idx_init
eidx_gc_scan_inboxes($self, $sync);
local $self->{nrec} = 0;
local $self->{-opt} = $opt;
local $self->{-regen_fmt} = "%u/?\n";
+ local $self->{latest_cmt};
my $sync = {
# DO NOT SET {reindex} here, it's incompatible with reused
# V2Writable code, reindex is totally different here
sub update_last_commit { # overrides V2Writable
my ($self, $sync, $stk) = @_;
my $unit = $sync->{unit} // return;
- my $latest_cmt = $stk ? $stk->{latest_cmt} : ${$sync->{latest_cmt}};
+ my $latest_cmt = $stk ? $stk->{latest_cmt} : $self->{latest_cmt};
defined($latest_cmt) or return;
my $ibx = $sync->{ibx} or die 'BUG: {ibx} missing';
my $ekey = $ibx->eidx_key;
sub new {
open(my $io, '+>', undef);
# latest_cmt is still useful when the newest revision is a `d'(elete),
- # otherwise we favor $sync->{latest_cmt} for checkpoints and {quit}
+ # otherwise we favor $self->{latest_cmt} for checkpoints and {quit}
bless { wr => $io, latest_cmt => $_[1] }, __PACKAGE__
}
++$self->{nidx};
++$self->{nrec};
my $cur_cmt = $sync->{cur_cmt} // die 'BUG: {cur_cmt} missing';
- ${$sync->{latest_cmt}} = $cur_cmt;
+ $self->{latest_cmt} = $cur_cmt;
}
sub unindex_both { # git->cat_async callback
unindex_eml($self, $oid, PublicInbox::Eml->new($bref));
# may be undef if leftover
if (defined(my $cur_cmt = $sync->{cur_cmt})) {
- ${$sync->{latest_cmt}} = $cur_cmt;
+ $self->{latest_cmt} = $cur_cmt;
}
++$self->{nidx};
}
$self->{need_checkpoint} = 0;
# $newest may be undef
- my $newest = $stk ? $stk->{latest_cmt} : ${$sync->{latest_cmt}};
+ my $newest = $stk ? $stk->{latest_cmt} : $self->{latest_cmt};
if (defined($newest)) {
my $cur = $self->{mm}->last_commit;
if (need_update($self, $sync, $cur, $newest)) {
$self->{nrec} = 0;
$sync->{sidx} = $self;
local $self->{need_checkpoint} = 0;
- $sync->{latest_cmt} = \(my $latest_cmt);
+ local $self->{latest_cmt};
$self->{mm}->{dbh}->begin_work;
if (my @leftovers = keys %{delete($sync->{D}) // {}}) {
my ($arg, $index) = @_;
++$arg->{self}->{nidx};
if (defined(my $cur = $arg->{cur_cmt})) {
- ${$arg->{latest_cmt}} = $cur;
+ $arg->{self}->{latest_cmt} = $cur;
} elsif ($index) {
die 'BUG: {cur_cmt} missing';
} # else { unindexing @leftovers doesn't set {cur_cmt}
sub update_last_commit {
my ($self, $sync, $stk) = @_;
my $unit = $sync->{unit} // return;
- my $latest_cmt = $stk ? $stk->{latest_cmt} : ${$sync->{latest_cmt}};
+ my $latest_cmt = $stk ? $stk->{latest_cmt} : $self->{latest_cmt};
defined($latest_cmt) or return;
my $last = last_epoch_commit($self, $unit->{epoch});
if (defined $last && is_ancestor($self->git, $last, $latest_cmt)) {
$pfx //= $unit->{git}->{git_dir};
}
local $self->{current_info} = "$pfx ";
- local $sync->{latest_cmt} = \(my $latest_cmt);
+ local $self->{latest_cmt};
local $sync->{unit} = $unit;
while (my ($f, $at, $ct, $oid, $cmt) = $stk->pop_rec) {
if ($sync->{quit}) {