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=-3.9 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 D833520193 for ; Mon, 28 Nov 2022 05:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613561; bh=G7Pbt4FIXfXUSu0Bvx2RBFmwSXYqdh61BfxZpQgPOOQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kqw4TmhikxT6gYCB5/7uTWSgpUHb8m7PDC+mfxZm/zjDHXGWSWBu6lSgh1ZXGdrpU TIqrrOFsm01EH6hqsqYilu+vVJXhauHTK0OlhgwtTa98k/2MGola7NbZ3h15dRriHc nWyQ+hU36c3HJrG0n5jiP8LDV+i2vSjqPNS0/9h4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 44/95] lei_mirror: simplify clone_v2_prep Date: Mon, 28 Nov 2022 05:31:41 +0000 Message-Id: <20221128053232.291618-45-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: Since everything relies on the instance-specific {todo} queue, there's no need to have sub-specific queues. --- lib/PublicInbox/LeiMirror.pm | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index b2745295..de4cdc22 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -433,7 +433,8 @@ sub clone_v2_prep ($$;$) { my $want = parse_epochs($lei->{opt}->{epoch}, $v2_epochs); my $task = $m ? bless { %$self }, __PACKAGE__ : $self; delete $task->{todo}; # $self->{todo} still exists - my (@src_edst, @skip, $desc, @entv); + my (@skip, $desc); + my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task); for my $nr (sort { $a <=> $b } keys %$v2_epochs) { my ($uri, $key) = @{$v2_epochs->{$nr}}; my $src = $uri->as_string; @@ -453,8 +454,13 @@ failed to extract epoch number from $src } } if (!$want || $want->{$nr}) { - push @src_edst, $src, $edst; - push @entv, $edst, $ent; + my $etask = bless { %$task }, __PACKAGE__; + $etask->{-ent} = $ent; # may have {reference} + $etask->{cur_src} = $src; + $etask->{cur_dst} = $edst; + $etask->{-is_epoch} = $fini; + my $ref = $ent->{reference} // ''; + push @{$self->{todo}->{$ref}}, $etask; $self->{any_want}->{$key} = 1; } else { # create a placeholder so users only need to chmod +w init_placeholder($src, $edst, $ent); @@ -467,24 +473,11 @@ failed to extract epoch number from $src (!$self->{dry_run} && !-d $dst) and File::Path::mkpath($dst); - my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task); - $lei->{opt}->{'inbox-config'} =~ /\A(?:always|v2)\z/s and _get_txt_start($task, '_/text/config/raw', $fini); defined($desc) ? ($task->{'txt.description'} = $desc) : _get_txt_start($task, 'description', $fini); - while (@entv) { - my ($edst, $ent) = splice(@entv, 0, 2); - my $etask = bless { %$task }, __PACKAGE__; - $etask->{-ent} = $ent; # may have {reference} - $etask->{cur_src} = shift @src_edst // die 'BUG: no cur_src'; - $etask->{cur_dst} = shift @src_edst // die 'BUG: no cur_dst'; - $etask->{cur_dst} eq $edst or - die "BUG: `$etask->{cur_dst}' != `$edst'"; - $etask->{-is_epoch} = $fini; - push @{$self->{todo}->{($ent->{reference} // '')}}, $etask; - } } sub decode_manifest ($$$) {