]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: require PublicInbox::Lock at use
authorEric Wong <e@80x24.org>
Mon, 28 Nov 2022 05:31:28 +0000 (05:31 +0000)
committerEric Wong <e@80x24.org>
Mon, 28 Nov 2022 23:38:55 +0000 (23:38 +0000)
It's easier to understand why we lazy-load Lock for v2-only
code paths when we require it near its first use.

lib/PublicInbox/LeiMirror.pm

index 2b20873ead918a0a5e8fb959ce101e6cb1653246..a7ddfcd2834a11146f762af48d6da7cab7add198 100644 (file)
@@ -384,6 +384,7 @@ sub v2_done { # called via OnDestroy
        my ($self) = @_;
        return if $self->{dry_run} || !$LIVE;
        my $dst = $self->{cur_dst} // $self->{dst};
+       require PublicInbox::Lock;
        my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock';
        my $lck = $lk->lock_for_scope($$);
        _write_inbox_config($self);
@@ -461,7 +462,6 @@ failed to extract epoch number from $src
 
        (!$self->{dry_run} && !-d $dst) and File::Path::mkpath($dst);
 
-       require PublicInbox::Lock;
        my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task);
 
        $lei->{opt}->{'inbox-config'} =~ /\A(?:always|v2)\z/s and