X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FInbox.pm;h=06ce9ebf8c464c3236760a17c60a686f430e8663;hb=95bdac7f09c69036efed537a4d03d5bdd2ae4eb6;hp=b76d4e5abb017383f831af4a97c73903e7cfa80a;hpb=227a1d886672767e37cc86a3432952c14eb8a143;p=public-inbox.git diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index b76d4e5a..06ce9ebf 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2019 all contributors +# Copyright (C) 2016-2020 all contributors # License: AGPL-3.0+ # # Represents a public-inbox (which may have multiple mailing addresses) @@ -219,25 +219,19 @@ sub try_cat { sub description { my ($self) = @_; - my $desc = $self->{description}; - return $desc if defined $desc; - $desc = try_cat("$self->{inboxdir}/description"); - local $/ = "\n"; - chomp $desc; - $desc =~ s/\s+/ /smg; - $desc = '($INBOX_DIR/description missing)' if $desc eq ''; - $self->{description} = $desc; + $self->{description} //= do { + my $desc = try_cat("$self->{inboxdir}/description"); + local $/ = "\n"; + chomp $desc; + $desc =~ s/\s+/ /smg; + $desc eq '' ? '($INBOX_DIR/description missing)' : $desc; + }; } sub cloneurl { my ($self) = @_; - my $url = $self->{cloneurl}; - return $url if $url; - $url = try_cat("$self->{inboxdir}/cloneurl"); - my @url = split(/\s+/s, $url); - local $/ = "\n"; - chomp @url; - $self->{cloneurl} = \@url; + $self->{cloneurl} //= + [ split(/\s+/s, try_cat("$self->{inboxdir}/cloneurl")) ]; } sub base_url { @@ -311,9 +305,9 @@ sub nntp_usable { $ret; } +# for v1 users w/o SQLite only sub msg_by_path ($$;$) { my ($self, $path, $ref) = @_; - # TODO: allow other refs: my $str = git($self)->cat_file('HEAD:'.$path, $ref); $$str =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s if $str; $str;