]> git.sesse.net Git - pr0n/blobdiff - perl/Sesse/pr0n/Common.pm
Remove some debugging code.
[pr0n] / perl / Sesse / pr0n / Common.pm
index e545e91d9e5a06704a2bc30baf949a3badaf95dd..d5e672746a3b8708777cf51e469fa3c037ee31e4 100644 (file)
@@ -31,7 +31,7 @@ BEGIN {
                require Sesse::pr0n::Config_local;
        };
 
-       $VERSION     = "v2.04";
+       $VERSION     = "v2.05";
        @ISA         = qw(Exporter);
        @EXPORT      = qw(&error &dberror);
        %EXPORT_TAGS = qw();
@@ -192,8 +192,8 @@ sub update_width_height {
 
        # update the last_picture cache as well (this should of course be done
        # via a trigger, but this is less complicated :-) )
-       $dbh->do('UPDATE events SET last_picture=(SELECT COALESCE(MAX(date),\'1970-01-01 00:00:00\') FROM images WHERE event=events.id) WHERE id=(SELECT event FROM images WHERE id=?)',
-               undef, $id)
+       $dbh->do('UPDATE last_picture_cache SET last_picture=GREATEST(last_picture, ?) WHERE event=(SELECT event FROM images WHERE id=?)',
+               undef, $datetime, $id)
                or die "Couldn't update last_picture in SQL: $!";
 }
 
@@ -269,7 +269,7 @@ sub ensure_cached {
        my ($r, $filename, $id, $dbwidth, $dbheight, $infobox, $xres, $yres, @otherres) = @_;
 
        my $fname = get_disk_location($r, $id);
-       unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || $dbwidth == -1 || $dbheight == -1)) {
+       unless (defined($xres) && ($xres < $dbheight || $yres < $dbwidth || $dbwidth == -1 || $dbheight == -1 || $xres == -1)) {
                return ($fname, 0);
        }
 
@@ -288,7 +288,6 @@ sub ensure_cached {
 
                # NEF files aren't autodetected
                $fname = "NEF:$fname" if ($filename =~ /\.nef$/i);
-               $r->log->warn("Generating $fname for $filename");
                
                my $err = $magick->Read($fname);
                if ($err) {
@@ -341,9 +340,11 @@ sub ensure_cached {
                                $quality = 80;
                        }
 
-                       $cimg->Resize(width=>$nwidth, height=>$nheight, filter=>$filter);
+                       if ($xres != -1) {
+                               $cimg->Resize(width=>$nwidth, height=>$nheight, filter=>$filter);
+                       }
 
-                       if (($nwidth >= 800 || $nheight >= 600) && $infobox == 1) {
+                       if (($nwidth >= 800 || $nheight >= 600 || $xres == -1) && $infobox == 1) {
                                make_infobox($cimg, $info, $r);
                        }
 
@@ -436,9 +437,11 @@ sub make_infobox {
        }
 
        if (defined($info->{'Flash'})) {
-               if ($info->{'Flash'} =~ /did not fire/ || $info->{'Flash'} =~ /No Flash/) {
+               if ($info->{'Flash'} =~ /did not fire/i ||
+                   $info->{'Flash'} =~ /no flash/i ||
+                   $info->{'Flash'} =~ /not fired/i)  {
                        push @lines, "No flash";
-               } elsif ($info->{'Flash'} =~ /fired/) {
+               } elsif ($info->{'Flash'} =~ /fired/i) {
                        push @lines, "Flash";
                } else {
                        push @lines, $info->{'Flash'};