]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/V2Writable.pm
v2writable: set unindexed article number
[public-inbox.git] / lib / PublicInbox / V2Writable.pm
index 45250923d3325e07aafaf4bb8c2f01fa2ac55a11..dcbbbc77761750c5b69246a2ba0837920fffc709 100644 (file)
@@ -76,7 +76,7 @@ sub new {
        # $creat may be any true value, or 0/undef.  A hashref is true,
        # and $creat->{nproc} may be set to an integer
        my ($class, $v2ibx, $creat) = @_;
-       my $dir = $v2ibx->{mainrepo} or die "no mainrepo in inbox\n";
+       my $dir = $v2ibx->{inboxdir} or die "no inboxdir in inbox\n";
        unless (-d $dir) {
                if ($creat) {
                        require File::Path;
@@ -304,7 +304,7 @@ sub idx_init {
                # Now that all subprocesses are up, we can open the FDs
                # for SQLite:
                my $mm = $self->{mm} = PublicInbox::Msgmap->new_file(
-                       "$self->{-inbox}->{mainrepo}/msgmap.sqlite3", 1);
+                       "$self->{-inbox}->{inboxdir}/msgmap.sqlite3", 1);
                $mm->{dbh}->begin_work;
        });
 }
@@ -315,7 +315,7 @@ sub idx_init {
 sub _replace_oids ($$$) {
        my ($self, $mime, $replace_map) = @_;
        $self->done;
-       my $pfx = "$self->{-inbox}->{mainrepo}/git";
+       my $pfx = "$self->{-inbox}->{inboxdir}/git";
        my $rewrites = []; # epoch => commit
        my $max = $self->{epoch_max};
 
@@ -663,16 +663,12 @@ sub done {
 sub fill_alternates ($$) {
        my ($self, $epoch) = @_;
 
-       my $pfx = "$self->{-inbox}->{mainrepo}/git";
-       my $all = "$self->{-inbox}->{mainrepo}/all.git";
-       my @cmd;
+       my $pfx = "$self->{-inbox}->{inboxdir}/git";
+       my $all = "$self->{-inbox}->{inboxdir}/all.git";
+
        unless (-d $all) {
                PublicInbox::Import::init_bare($all);
        }
-       @cmd = (qw/git config/, "--file=$pfx/$epoch.git/config",
-                       'include.path', '../../all.git/config');
-       PublicInbox::Import::run_die(\@cmd);
-
        my $alt = "$all/objects/info/alternates";
        my %alts;
        my @add;
@@ -694,9 +690,12 @@ sub fill_alternates ($$) {
 
 sub git_init {
        my ($self, $epoch) = @_;
-       my $git_dir = "$self->{-inbox}->{mainrepo}/git/$epoch.git";
+       my $git_dir = "$self->{-inbox}->{inboxdir}/git/$epoch.git";
        my @cmd = (qw(git init --bare -q), $git_dir);
        PublicInbox::Import::run_die(\@cmd);
+       @cmd = (qw/git config/, "--file=$git_dir/config",
+                       'include.path', '../../all.git/config');
+       PublicInbox::Import::run_die(\@cmd);
        fill_alternates($self, $epoch);
        $git_dir
 }
@@ -704,7 +703,7 @@ sub git_init {
 sub git_dir_latest {
        my ($self, $max) = @_;
        $$max = -1;
-       my $pfx = "$self->{-inbox}->{mainrepo}/git";
+       my $pfx = "$self->{-inbox}->{inboxdir}/git";
        return unless -d $pfx;
        my $latest;
        opendir my $dh, $pfx or die "opendir $pfx: $!\n";
@@ -936,7 +935,7 @@ sub update_last_commit ($$$$) {
        last_epoch_commit($self, $i, $cmt);
 }
 
-sub git_dir_n ($$) { "$_[0]->{-inbox}->{mainrepo}/git/$_[1].git" }
+sub git_dir_n ($$) { "$_[0]->{-inbox}->{inboxdir}/git/$_[1].git" }
 
 sub last_commits ($$) {
        my ($self, $epoch_max) = @_;
@@ -1073,7 +1072,7 @@ sub unindex_oid ($$$) {
                                join(',',sort keys %gone), "\n";
                }
                foreach my $num (keys %gone) {
-                       $self->{unindexed}->{$_}++;
+                       $self->{unindexed}->{$num}++;
                        $self->{mm}->num_delete($num);
                }
                unindex_oid_remote($self, $oid, $mid);