]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NewsGroup.pm
rename 'GitCatFile' package to 'Git'
[public-inbox.git] / lib / PublicInbox / NewsGroup.pm
index 1250b0d84db3c9881da0b06a145446f0b3032b60..b20180e6667aceebd0a1feb516118f38603fa69f 100644 (file)
@@ -1,12 +1,16 @@
 # Copyright (C) 2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+#
+# Used only by the NNTP server to represent a public-inbox git repository
+# as a newsgroup
 package PublicInbox::NewsGroup;
 use strict;
 use warnings;
 use Scalar::Util qw(weaken);
 require Danga::Socket;
 require PublicInbox::Msgmap;
-require PublicInbox::GitCatFile;
+require PublicInbox::Search;
+require PublicInbox::Git;
 
 sub new {
        my ($class, $name, $git_dir, $address) = @_;
@@ -28,7 +32,7 @@ sub defer_weaken {
 sub gcf {
        my ($self) = @_;
        $self->{gcf} ||= eval {
-               my $gcf = PublicInbox::GitCatFile->new($self->{git_dir});
+               my $gcf = PublicInbox::Git->new($self->{git_dir});
 
                # git repos may be repacked and old packs unlinked
                defer_weaken($self, 'gcf');
@@ -36,11 +40,16 @@ sub gcf {
        };
 }
 
+sub usable {
+       my ($self) = @_;
+       eval {
+               PublicInbox::Msgmap->new($self->{git_dir});
+               PublicInbox::Search->new($self->{git_dir});
+       };
+}
+
 sub mm {
-       my ($self, $check_only) = @_;
-       if ($check_only) {
-               return eval { PublicInbox::Msgmap->new($self->{git_dir}) };
-       }
+       my ($self) = @_;
        $self->{mm} ||= eval {
                my $mm = PublicInbox::Msgmap->new($self->{git_dir});
 
@@ -53,7 +62,6 @@ sub mm {
 sub search {
        my ($self) = @_;
        $self->{search} ||= eval {
-               require PublicInbox::Search;
                my $search = PublicInbox::Search->new($self->{git_dir});
 
                # may be needed if we run low on handles