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 509071FB01 for ; Mon, 28 Nov 2022 05:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613556; bh=84v3kvu7cww99amDnHYgNXcSPEqJdUxsidI46WxRNus=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Hz61VFh8b+q135d1FvvXW/ElCkhcb2kzKqJKKXx33cWUHMFwgh4E6roByLQ5I5Uyq k+ynR+RXtgQE509JbRgv2jJI1NnrwoHNSnaaSlpSioMk8+YgpYwlZnKsPFmLFU+A53 NAJSCwFM+uKnaAjpbUQBfRYTCS1zTz9McvjfRP44= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 18/95] lei_mirror: load most modules up-front Date: Mon, 28 Nov 2022 05:31:15 +0000 Message-Id: <20221128053232.291618-19-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: lei lazy loads LeiMirror itself lazily, anyways, and it only supports HTTP(S) mirrors, so there's no point in delaying most of the modules it loads. Some of the inbox-specific and v2-specific stuff can be lazy-loaded, however, since this will support mirroring non-inbox repositories, too. --- lib/PublicInbox/LeiMirror.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 1ca603b3..d0bc7384 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -6,7 +6,6 @@ package PublicInbox::LeiMirror; use strict; use v5.10.1; use parent qw(PublicInbox::IPC); -use PublicInbox::Config; use IO::Uncompress::Gunzip qw(gunzip $GunzipError); use IO::Compress::Gzip qw(gzip $GzipError); use PublicInbox::Spawn qw(popen_rd spawn); @@ -14,7 +13,13 @@ use File::Path (); use File::Temp (); use Fcntl qw(SEEK_SET O_CREAT O_EXCL O_WRONLY); use Carp qw(croak); -our %LIVE; +use URI; +use PublicInbox::Config; +use PublicInbox::Inbox; +use PublicInbox::LeiCurl; +use PublicInbox::OnDestroy; + +our %LIVE; # pid => callback sub _wq_done_wait { # dwaitpid callback (via wq_eof) my ($arg, $pid) = @_; @@ -191,6 +196,8 @@ sub index_cloned_inbox { # n.b. public-inbox-clone works w/o (SQLite || Xapian) # lei is useless without Xapian + SQLite if ($lei->{cmd} ne 'public-inbox-clone') { + require PublicInbox::InboxWritable; + require PublicInbox::Admin; my $ibx = delete($self->{ibx}) // { address => [ 'lei@example.com' ], version => $iv, @@ -389,6 +396,7 @@ failed to extract epoch number from $src $self->{-culled_manifest} = 1 if delete(@$m{@skip}); -d $dst || File::Path::mkpath($dst); + require PublicInbox::Lock; my $lk = bless { lock_path => "$dst/inbox.lock" }, 'PublicInbox::Lock'; my $fini = PublicInbox::OnDestroy->new($$, \&v2_done, $task); @@ -595,14 +603,6 @@ sub do_mirror { # via wq_io_do sub start { my ($cls, $lei, $src, $dst) = @_; my $self = bless { src => $src, dst => $dst }, $cls; - if ($src =~ m!https?://!) { - require URI; - require PublicInbox::LeiCurl; - } - require PublicInbox::Lock; - require PublicInbox::Inbox; - require PublicInbox::Admin; - require PublicInbox::InboxWritable; $lei->request_umask; my ($op_c, $ops) = $lei->workers_start($self, 1); $lei->{wq1} = $self;