X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FInbox.pm;h=3532bb584236d4d466d12c234e338867699b5936;hb=a002384a74382df2649d6a1f8dfba4f291af032e;hp=8ac7eb302a0c6ed9ef7b9b97f53888bcc115d866;hpb=a93c7e471ca70bdb476c2285cf894e319b38f160;p=public-inbox.git diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm index 8ac7eb30..3532bb58 100644 --- a/lib/PublicInbox/Inbox.pm +++ b/lib/PublicInbox/Inbox.pm @@ -181,33 +181,18 @@ sub over { } // ($req ? croak("E: $@") : undef); } -sub try_cat { - my ($path) = @_; - open(my $fh, '<', $path) or return ''; - local $/; - <$fh> // ''; -} - -sub cat_desc ($) { - my $desc = try_cat($_[0]); - local $/ = "\n"; - chomp $desc; - utf8::decode($desc); - $desc =~ s/\s+/ /smg; - $desc eq '' ? undef : $desc; -} - sub description { my ($self) = @_; - ($self->{description} //= cat_desc("$self->{inboxdir}/description")) // + ($self->{description} //= + PublicInbox::Git::cat_desc("$self->{inboxdir}/description")) // '($INBOX_DIR/description missing)'; } sub cloneurl { my ($self) = @_; $self->{cloneurl} // do { - my $s = try_cat("$self->{inboxdir}/cloneurl"); - my @urls = split(/\s+/s, $s); + my @urls = split(/\s+/s, + PublicInbox::Git::try_cat("$self->{inboxdir}/cloneurl")); scalar(@urls) ? ($self->{cloneurl} = \@urls) : undef; } // []; }