X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FManifestJsGz.pm;h=d5048a96de45da8589cc659fff787588a941c64a;hb=23af251dd607c4e75ab1e68063f2c885c48cc035;hp=9dc10791ea4415cf92ad78016df7a8d2f70358ba;hpb=5860b498af67dc0944c39667e3899485b5650387;p=public-inbox.git diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm index 9dc10791..d5048a96 100644 --- a/lib/PublicInbox/ManifestJsGz.pm +++ b/lib/PublicInbox/ManifestJsGz.pm @@ -6,18 +6,17 @@ package PublicInbox::ManifestJsGz; use strict; use v5.10.1; use parent qw(PublicInbox::WwwListing); -use bytes (); # length use PublicInbox::Config; use IO::Compress::Gzip qw(gzip); use HTTP::Date qw(time2str); my $json = PublicInbox::Config::json(); -sub url_regexp { +sub url_filter { my ($ctx) = @_; # grokmirror uses relative paths, so it's domain-dependent # SUPER calls PublicInbox::WwwListing::url_filter - ($ctx->url_filter('publicInbox.grokManifest', 'match=domain'))[0]; + $ctx->SUPER::url_filter('publicInbox.grokManifest', 'match=domain'); } sub inject_entry ($$$;$) { @@ -28,7 +27,7 @@ sub inject_entry ($$$;$) { $ctx->{manifest}->{$url_path} = $ent; } -sub manifest_add ($$;$$) { # slow path w/o extindex "all" +sub manifest_add ($$;$$) { # slow path w/o extindex "all" (or per-inbox) my ($ctx, $ibx, $epoch, $default_desc) = @_; my $url_path = "/$ibx->{name}"; my $git; @@ -54,6 +53,7 @@ sub slow_manifest_add ($$) { manifest_add($ctx, $ibx); } }; + warn "E: $@" if $@; } sub eidx_manifest_add ($$$) { @@ -66,6 +66,10 @@ sub eidx_manifest_add ($$$) { } } else { warn "E: `${\$ibx->eidx_key}' not indexed by $ALL->{topdir}\n"; + # do not use slow path for global manifest since + # it can become catastrophically slow. per-inbox manifest + # is not too bad with dozens of epochs, so never fail that: + slow_manifest_add($ctx, $ibx) if $ibx == $ctx->{ibx}; } } @@ -86,12 +90,8 @@ sub response { sub ibx_entry { my ($ctx, $ibx) = @_; my $ALL = $ctx->{www}->{pi_cfg}->ALL; - if ($ALL) { # FIXME: test this in t/ - eidx_manifest_add($ctx, $ALL, $ibx); - } else { + $ALL ? eidx_manifest_add($ctx, $ALL, $ibx) : slow_manifest_add($ctx, $ibx); - warn "E: $@" if $@; - } } sub hide_key { 'manifest' } # for WwwListing->list_match_i @@ -108,13 +108,12 @@ sub psgi_triple { gzip(\$manifest => \(my $out)); [ 200, [ qw(Content-Type application/gzip), 'Last-Modified', time2str($ctx->{-mtime}), - 'Content-Length', bytes::length($out) ], [ $out ] ] + 'Content-Length', length($out) ], [ $out ] ] } sub per_inbox { my ($ctx) = @_; - # only one inbox, slow is probably OK - slow_manifest_add($ctx, $ctx->{ibx}); + ibx_entry($ctx, $ctx->{ibx}); psgi_triple($ctx); }