diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:32:32 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:39:00 +0000 |
commit | eb22c4833d455b655b42b492dfad7f2abfc83203 (patch) | |
tree | 06685dd704ab662e070eb205a60c9b907e36258b | |
parent | 556fb7af0e43c1183933d6afe451eb81296b802c (diff) | |
download | public-inbox-eb22c4833d455b655b42b492dfad7f2abfc83203.tar.gz |
Forkgroups for projects are not static and may change at the whim of the remote sysadmin. Ensure we can migrate to the new forkgroup. Old forkgroups do not get pruned, yet, and their entries stay in alternates.
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index d4b14699..33cf55ab 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -428,20 +428,9 @@ sub forkgroup_prep { my $key = $self->{-key} // die 'BUG: no -key'; my $rn = substr(sha256_hex($key), 0, 16); if (!-d $self->{cur_dst} && !$self->{dry_run}) { - my $alt = File::Spec->rel2abs("$dir/objects"); PublicInbox::Import::init_bare($self->{cur_dst}); - my $o = "$self->{cur_dst}/objects"; - my $f = "$o/info/alternates"; - my $l = File::Spec->abs2rel($alt, File::Spec->rel2abs($o)); - open my $fh, '+>>', $f or die "open($f): $!"; - seek($fh, SEEK_SET, 0) or die "seek($f): $!"; - chomp(my @cur = <$fh>); - if (!grep(/\A\Q$l\E\z/, @cur)) { - say $fh $l or die "say($f): $!"; - } - close $fh or die "close($f): $!"; - $f = "$self->{cur_dst}/config"; - open $fh, '+>>', $f or die "open:($f): $!"; + my $f = "$self->{cur_dst}/config"; + open my $fh, '+>>', $f or die "open:($f): $!"; print $fh <<EOM or die "print($f): $!"; ; rely on the "$rn" remote in the ; $fg fork group for fetches @@ -453,6 +442,19 @@ sub forkgroup_prep { EOM close $fh or die "close($f): $!"; } + if (!$self->{dry_run}) { + my $alt = File::Spec->rel2abs("$dir/objects"); + my $o = "$self->{cur_dst}/objects"; + my $f = "$o/info/alternates"; + my $l = File::Spec->abs2rel($alt, File::Spec->rel2abs($o)); + open my $fh, '+>>', $f or die "open($f): $!"; + seek($fh, SEEK_SET, 0) or die "seek($f): $!"; + chomp(my @cur = <$fh>); + if (!grep(/\A\Q$l\E\z/, @cur)) { + say $fh $l or die "say($f): $!"; + } + close $fh or die "close($f): $!"; + } bless { %$self, -osdir => $dir, -remote => $rn, -uri => $uri }, __PACKAGE__; |