From: Steinar H. Gunderson Date: Sat, 5 Jun 2021 21:20:18 +0000 (+0200) Subject: Small simplification. X-Git-Url: https://git.sesse.net/?p=pr0n;a=commitdiff_plain;h=2ef4a7400c399979fdc891e8ff84d63fa64d79ad Small simplification. --- diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 52d6ee2..4839285 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -574,8 +574,6 @@ sub read_original_image { sub ensure_cached { my ($r, $filename, $id, $dbwidth, $dbheight, $xres, $yres, @otherres) = @_; - my ($new_dbwidth, $new_dbheight); - my $fname = get_disk_location($r, $id); unless (defined($xres) && (!defined($dbwidth) || !defined($dbheight) || $xres < $dbwidth || $yres < $dbheight || $xres == -1)) { return ($fname, undef); @@ -591,8 +589,13 @@ sub ensure_cached { error($r, 'System is in overload mode, not doing any scaling'); } - my $img; - ($img, $new_dbwidth, $new_dbheight) = make_mipmap($r, $filename, $id, $dbwidth, $dbheight, $xres, $yres, @otherres); + my ($img, $new_dbwidth, $new_dbheight) = make_mipmap($r, $filename, $id, $dbwidth, $dbheight, $xres, $yres, @otherres); + + # Update the SQL database if it doesn't contain the required info + if (!defined($dbwidth) && defined($new_dbwidth)) { + log_info($r, "Updating width/height for $id: $new_dbwidth x $new_dbheight"); + update_image_info($r, $id, $new_dbwidth, $new_dbheight); + } while (defined($xres) && defined($yres)) { my ($nxres, $nyres) = (shift @otherres, shift @otherres); @@ -654,12 +657,6 @@ sub ensure_cached { } } } - - # Update the SQL database if it doesn't contain the required info - if (!defined($dbwidth) && defined($new_dbwidth)) { - log_info($r, "Updating width/height for $id: $new_dbwidth x $new_dbheight"); - update_image_info($r, $id, $new_dbwidth, $new_dbheight); - } return ($cachename, 'image/jpeg'); }