From 229d05b801df48b18c99ce5cdf6a8dc33b3b8f96 Mon Sep 17 00:00:00 2001 From: eleksir Date: Sat, 17 Mar 2018 23:23:31 +0300 Subject: [PATCH] img-save.pl: * fix download condition * when getting memcached keys we use only first slab in list, now all slabs are used, so we get full list of keys --- web_link_saver/img-save.pl | 50 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/web_link_saver/img-save.pl b/web_link_saver/img-save.pl index 5ca84cb..a23a2f6 100644 --- a/web_link_saver/img-save.pl +++ b/web_link_saver/img-save.pl @@ -69,31 +69,39 @@ while ( 1 ) { if (defined($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) and (length($itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}) > 2)) { - my $slabinfo = (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'}))[0]; - my $slab = (split(/\:/, $slabinfo))[1]; - my $itemsamount = (split(/ /, $slabinfo))[2]; - my $cachedump = $memd->stats(["cachedump $slab $itemsamount"]); + foreach my $stat (split("\n", $itemref->{'hosts'}->{'127.0.0.1:11211'}->{'items'})) { + my $slab; + my $itemsamount; - my @keys = map { - (split(/ /))[1]; - } split(/\n/, $cachedump->{'hosts'}->{'127.0.0.1:11211'}->{"cachedump $slab $itemsamount"}); + if ($stat =~ /^STAT items\:(\d+)\:number (\d+)/) { + $slab = $1; + $itemsamount = $2; + } else { + undef $slab; + undef $itemsamount; + next; + } - foreach my $key (@keys) { - next unless ($key =~ /^irssi_/); - next unless ($key =~ /^xchtlink_/); + my $cachedump = $memd->stats(["cachedump $slab $itemsamount"]); + my @keys = map { + (split(/ /))[1]; + } split(/\n/, $cachedump->{'hosts'}->{'127.0.0.1:11211'}->{"cachedump $slab $itemsamount"}); - my $url = $memd->get($key); - cdlfunc($url); - undef $url; - $memd->delete($key); + foreach my $key (@keys) { + if (($key =~ /^irssi_/) or ($key =~ /^xchtlink_/)) { + my $url = $memd->get($key); + cdlfunc($url); + undef $url; + $memd->delete($key); + } + } + + undef $slab; + undef $itemsamount; + undef $cachedump; + @keys = -1; + undef @keys; } - - undef $slabinfo; - undef $slab; - undef $itemsamount; - undef $cachedump; - @keys = -1; - undef @keys; } undef $itemref;