From 611036f0b55b809c5c4991ce4e4a6919006ad389 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Fri, 5 Aug 2016 18:10:01 +0000 Subject: [PATCH] Libravatar: Add caching of "negative" libravatar results Signed-off-by: Niels Thykier --- Debbugs/Libravatar.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 -- 2.39.2