X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=perl%2Fupdate-image-cache.pl;h=f50d3a0b046b5539d820bbe8365a52dbc398845e;hb=c8c8d4ba8a2e5a3c8b6a6b787a354f72c29964e2;hp=a159e3747454f939fc9361f69c2d46692aa5ceb5;hpb=4992c11ab93bf6f13eda229ff538b78c6bee1441;p=pr0n diff --git a/perl/update-image-cache.pl b/perl/update-image-cache.pl index a159e37..f50d3a0 100755 --- a/perl/update-image-cache.pl +++ b/perl/update-image-cache.pl @@ -51,6 +51,8 @@ sub warn { sub error { print STDERR $_[1], "\n"; } +sub logger { +} package main; use Sesse::pr0n::Common; @@ -101,8 +103,6 @@ while (my $ref = $q->fetchrow_hashref) { if (!$regen_mipmaps) { @files = grep { !/mipmap/ } @files; } - my @bothres = (); - my @boxres = (); my @noboxres = (); my $any_old = 0; for my $c (@files) { @@ -110,24 +110,14 @@ while (my $ref = $q->fetchrow_hashref) { if ($mtime < $threshold) { $any_old = 1; } - if ($c =~ /$id-(\d+)-(\d+)\.jpg/ || $c =~ /$id-(-1)-(-1)\.jpg/) { - push @bothres, [$1, $2]; - } elsif ($c =~ /$id-(\d+)-(\d+)-nobox\.jpg/ || $c =~ /$id-(-1)-(-1)-nobox\.jpg/) { + if ($c =~ /$id-(\d+)-(\d+)-nobox\.jpg/ || $c =~ /$id-(-1)-(-1)-nobox\.jpg/) { push @noboxres, [$1, $2]; - } elsif ($c =~ /$id-(\d+)-(\d+)-box\.png/ || $c =~ /$id-(-1)-(-1)-box\.png/) { - push @boxres, [$1, $2]; } } next unless $any_old; - unlink (@files); - if (scalar @bothres > 0) { - Sesse::pr0n::Common::ensure_cached($r, $ref->{'filename'}, $id, $ref->{'width'}, $ref->{'height'}, 'both', sort_res(@bothres)); - } + unlink (@files) or die "Could not delete: $!"; if (scalar @noboxres > 0) { - Sesse::pr0n::Common::ensure_cached($r, $ref->{'filename'}, $id, $ref->{'width'}, $ref->{'height'}, 'nobox', sort_res(@noboxres)); - } - if (scalar @boxres > 0) { - Sesse::pr0n::Common::ensure_cached($r, $ref->{'filename'}, $id, $ref->{'width'}, $ref->{'height'}, 'box', sort_res(@boxres)); + Sesse::pr0n::Common::ensure_cached($r, $ref->{'filename'}, $id, $ref->{'width'}, $ref->{'height'}, sort_res(@noboxres)); } my @newfiles = glob("../cache/$dir/$id-*.jpg");