From: Niels Thykier Date: Fri, 5 Aug 2016 18:10:01 +0000 (+0000) Subject: Libravatar: Add caching of "negative" libravatar results X-Git-Tag: release/2.6.0~166 X-Git-Url: https://git.donarmstrong.com/?p=debbugs.git;a=commitdiff_plain;h=611036f0b55b809c5c4991ce4e4a6919006ad389 Libravatar: Add caching of "negative" libravatar results Signed-off-by: Niels Thykier --- diff --git a/Debbugs/Libravatar.pm b/Debbugs/Libravatar.pm index 0c84943..883305f 100644 --- a/Debbugs/Libravatar.pm +++ b/Debbugs/Libravatar.pm @@ -118,7 +118,18 @@ sub retrieve_libravatar{ $ua->max_size(30*1024); my $r = $ua->get($uri); if (not $r->is_success()) { - die "Not successful in request"; + if ($r->code != 404) { + die "Not successful in request"; + } + # No avatar - cache a negative result + if ($config{libravatar_default_image} =~ m/\.(png|jpg)$/) { + $dest_type = $1; + + system('cp', '-laf', $config{libravatar_default_image}, $cache_location.'.'.$dest_type) == 0 + or die("Cannot copy $config{libravatar_default_image}"); + # Returns from eval {} + return; + } } my $aborted = $r->header('Client-Aborted'); # if we exceeded max size, I'm not sure if we'll be