X-Git-Url: https://git.sesse.net/?p=pr0n;a=blobdiff_plain;f=perl%2FSesse%2Fpr0n%2FCommon.pm;h=8227c80db13562418ca335fc90bfd3da14bf2bd5;hp=9e56cee8397834b65946cba9bfe32a3584260b26;hb=80109fa17438d698875f3ff6877cbd205335b2e2;hpb=5b3eddb776fdf70189bcd480a9334700bfa7572f diff --git a/perl/Sesse/pr0n/Common.pm b/perl/Sesse/pr0n/Common.pm index 9e56cee..8227c80 100644 --- a/perl/Sesse/pr0n/Common.pm +++ b/perl/Sesse/pr0n/Common.pm @@ -34,7 +34,7 @@ BEGIN { require Sesse::pr0n::Config_local; }; - $VERSION = "v2.21"; + $VERSION = "v2.30"; @ISA = qw(Exporter); @EXPORT = qw(&error &dberror); %EXPORT_TAGS = qw(); @@ -198,28 +198,32 @@ sub update_image_info { } } - $dbh->do('UPDATE images SET width=?, height=?, date=? WHERE id=?', - undef, $width, $height, $datetime, $id) - or die "Couldn't update width/height in SQL: $!"; + { + local $dbh->{AutoCommit} = 0; - $dbh->do('DELETE FROM exif_info WHERE image=?', - undef, $id) - or die "Couldn't delete old EXIF information in SQL: $!"; + $dbh->do('UPDATE images SET width=?, height=?, date=? WHERE id=?', + undef, $width, $height, $datetime, $id) + or die "Couldn't update width/height in SQL: $!"; - my $q = $dbh->prepare('INSERT INTO exif_info (image,tag,value) VALUES (?,?,?)') - or die "Couldn't prepare inserting EXIF information: $!"; + $dbh->do('DELETE FROM exif_info WHERE image=?', + undef, $id) + or die "Couldn't delete old EXIF information in SQL: $!"; - for my $key (keys %$info) { - next if ref $info->{$key}; - $q->execute($id, $key, $info->{$key}) - or die "Couldn't insert EXIF information in database: $!"; - } + my $q = $dbh->prepare('INSERT INTO exif_info (image,tag,value) VALUES (?,?,?)') + or die "Couldn't prepare inserting EXIF information: $!"; - # update the last_picture cache as well (this should of course be done - # via a trigger, but this is less complicated :-) ) - $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: $!"; + for my $key (keys %$info) { + next if ref $info->{$key}; + $q->execute($id, $key, guess_charset($info->{$key})) + or die "Couldn't insert EXIF information in database: $!"; + } + + # update the last_picture cache as well (this should of course be done + # via a trigger, but this is less complicated :-) ) + $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: $!"; + } } sub check_access {