* [RFC] index: ensure git dumb HTTP works on mirrors
@ 2019-05-01 12:33 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-05-01 12:33 UTC (permalink / raw)
To: meta
Since our -mda and -watch deliveries run update-server-info to
support dumb HTTP, ensure mirrors using public-inbox-index also
support dumb HTTP.
post-update hooks aren't enabled by default on mirrors, but if
they are, the worst case is we needlessly update the timestamp
of the $GIT_DIR/info/refs file.
In v1, we must explicitly tell index_sync to update; since
the API was designed around indexing being optional.
In v2, index_sync is only used by the -index tool on
mirrors.
---
I'm pretty sure the minor timestamp descrepancy and extra
writes iff an existing post-update hook is enabled would
not be a big deal. Perhaps update-server-info could be
idempotent and not perform unnecessary writes in the future.
lib/PublicInbox/SearchIdx.pm | 6 ++++++
lib/PublicInbox/V2Writable.pm | 9 ++++++++-
script/public-inbox-index | 2 +-
t/convert-compact.t | 9 +++++++--
t/v2mirror.t | 3 +++
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index db0495b..6f98cf2 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -519,6 +519,7 @@ sub do_cat_mail {
sub index_sync {
my ($self, $opts) = @_;
+ $self->{server_info} = $opts->{server_info};
$self->{-inbox}->with_umask(sub { $self->_index_sync($opts) })
}
@@ -573,6 +574,11 @@ sub read_log {
$del_cb->($self, $mime);
}
$batch_cb->($latest, $newest);
+ if (defined $latest && $self->{server_info}) {
+ require PublicInbox::Import;
+ my @git = ('git', "--git-dir=$git->{git_dir}");
+ PublicInbox::Import::run_die([@git, 'update-server-info']);
+ }
}
sub _msgmap_init {
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 6829a34..b213d1d 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -960,7 +960,14 @@ sub index_sync {
}
$fh = undef;
delete $self->{reindex_pipe};
- $self->update_last_commit($git, $i, $cmt) if defined $cmt;
+ if (defined $cmt) {
+ $self->update_last_commit($git, $i, $cmt);
+ $self->{-inbox}->with_umask(sub {
+ PublicInbox::Import::run_die([
+ 'git', "--git-dir=$git_dir",
+ 'update-server-info' ]);
+ });
+ }
}
# unindex is required for leftovers if "deletes" affect messages
diff --git a/script/public-inbox-index b/script/public-inbox-index
index 5adb6e7..f1a105a 100755
--- a/script/public-inbox-index
+++ b/script/public-inbox-index
@@ -88,6 +88,6 @@ sub index_dir {
$v2w->index_sync({ reindex => $reindex, prune => $prune });
} else {
my $s = PublicInbox::SearchIdx->new($repo, 1);
- $s->index_sync({ reindex => $reindex });
+ $s->index_sync({ reindex => $reindex, server_info => 1 });
}
}
diff --git a/t/convert-compact.t b/t/convert-compact.t
index 491486d..6c22b32 100644
--- a/t/convert-compact.t
+++ b/t/convert-compact.t
@@ -98,10 +98,15 @@ is(((stat("$tmpdir/v2/msgmap.sqlite3"))[2]) & 07777, 0644,
@xdir = (glob("$tmpdir/v2/git/*.git/objects/*/*"),
glob("$tmpdir/v2/git/*.git/objects/pack/*"));
+my $msg = 'sharedRepository respected after v2 compact';
foreach (@xdir) {
my @st = stat($_);
- is($st[2] & 07777, -f _ ? 0444 : 0755,
- 'sharedRepository respected after v2 compact');
+ my $mode = $st[2] & 07777;
+ if ($_ =~ m!/objects/info/packs\z!) {
+ is(-f _ && $mode, 0644, $msg);
+ } else {
+ is($mode, -f _ ? 0444 : 0755, $msg);
+ }
}
my $msgs = $ibx->recent({limit => 1000});
is($msgs->[0]->{mid}, 'a-mid@b', 'message exists in history');
diff --git a/t/v2mirror.t b/t/v2mirror.t
index ef9a540..694604b 100644
--- a/t/v2mirror.t
+++ b/t/v2mirror.t
@@ -90,6 +90,9 @@ foreach my $i (0..$epoch_max) {
'alt@example.com');
is(system(@cmd), 0, 'initialized public-inbox -V2');
is(system("$script-index", "$tmpdir/m"), 0, 'indexed');
+foreach my $i (0..$epoch_max) {
+ ok(-r "$tmpdir/m/git/$i.git/info/refs", "#$i info/refs exists");
+}
my $mibx = { mainrepo => "$tmpdir/m", address => 'alt@example.com' };
$mibx = PublicInbox::Inbox->new($mibx);
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-01 12:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-01 12:33 [RFC] index: ensure git dumb HTTP works on mirrors Eric Wong
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).