From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1B3A8203D8 for ; Mon, 28 Nov 2022 05:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613573; bh=Zo4G8lLZCaKVv9ysZzbhzkTLy1yP/3dFE1P/h9dqUek=; h=From:To:Subject:Date:In-Reply-To:References:From; b=N9cU12l2Y6hqU75U8S9uDjoXSK18RDs5HBH3wIJyXT/h+k8MIed2dgV/yoj95EXDG e4gUtSXKV5VVDHRMD9ClLeOHyU0vHy6d4wduFcLhtauat95OX1go4QyRzHD5f+HGs4 Rt55DeXJ/C5SFjE0xpwFs4oVBiyprFVHuVwTIH2k= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 95/95] lei_mirror: handle forkgroup changes Date: Mon, 28 Nov 2022 05:32:32 +0000 Message-Id: <20221128053232.291618-96-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/LeiMirror.pm | 28 +++++++++++++++------------- 1 file 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 <{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__;