]> git.sesse.net Git - pr0n/commitdiff
Small simplification.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Jun 2021 21:20:18 +0000 (23:20 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 5 Jun 2021 21:20:18 +0000 (23:20 +0200)
perl/Sesse/pr0n/Common.pm

index 52d6ee2f61544c5101dc52a83905b0a2a746b764..4839285dba1b99ea3e790f90a5296d9fdfcb39e4 100644 (file)
@@ -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');
 }