summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-08-18 18:12:09 +0000
committeryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-08-18 18:12:09 +0000
commitc28e1bf6b01b8e1d082d8df8861c65db3be42b3e (patch)
tree8d35d1fe7317e7d4fec6a830cc4490c7c59c5af0
parent6e50d7f066d3dc64e65a3503431dff690df743fb (diff)
Found a definite and proper solution to fix the command synchronisation problems, fixed display of wrong ID for screenshot diff, and increased screenshot JPEG quality to 90
git-svn-id: svn://vndb.org/vndb@95 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
-rw-r--r--data/tpl/vnpage2
-rw-r--r--lib/Multi/IRC.pm2
-rw-r--r--lib/Multi/Image.pm6
-rw-r--r--lib/Multi/RG.pm1
-rw-r--r--lib/VNDB.pm5
-rw-r--r--lib/VNDB/Util/Tools.pm17
6 files changed, 20 insertions, 13 deletions
diff --git a/data/tpl/vnpage b/data/tpl/vnpage
index 2f6edd4f..a773a3a1 100644
--- a/data/tpl/vnpage
+++ b/data/tpl/vnpage
@@ -35,7 +35,7 @@
[ categories => 'Categories', sub { join(' ', map { my $l=$VNDB::CAT->{substr($_->[0],0,1)}[1]{substr($_->[0],1,2)}; $l?$l.'('.$_->[1].')':() } sort { $a->[0] cmp $b->[0] } @{$_[0]}) || 'No categories selected' }, 1 ],
[ relations => 'Relations', sub { join("<br />\n", map { $VNDB::VREL->[$_->{relation}].': '._hchar($_->{title}) } sort { $a->{id} <=> $b->{id} } @{$_[0]}) } ],
[ image => 'Image', sub { $_[0] > 0 ? sprintf '<img src="%s/cv/%02d/%d.jpg" />', $p{st}, $_[0]%100, $_[0] : $_[0] < 0 ? '[processing]' : 'No image'; } ],
- [ screenshots => 'Screenshots', sub { join "<br />\n", map sprintf('<a href="%s/sf/%02d/%d.jpg">%2$d</a> (%s)',$p{st},$$_{id}%100,$$_{id},$$_{nsfw}?'NSFW':'Safe'), @{$_[0]} } ],
+ [ screenshots => 'Screenshots', sub { join "<br />\n", map sprintf('<a href="%s/sf/%02d/%d.jpg">%3$d</a> (%s)',$p{st},$$_{id}%100,$$_{id},$$_{nsfw}?'NSFW':'Safe'), @{$_[0]} } ],
[ img_nsfw => 'NSFW', sub { $_[0] ? 'Not safe' : 'Safe' } ]
) ]]
[[ } ]]-
diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm
index 030c9ee2..4a60f324 100644
--- a/lib/Multi/IRC.pm
+++ b/lib/Multi/IRC.pm
@@ -257,7 +257,7 @@ sub vndbid { # dest, msg, force
sub ircnotify { # command, VNDBID
- $_[KERNEL]->delay(vndbid => 1 => $_ => $_[ARG1] => 1) for (@{$_[HEAP]{notify}});
+ $_[KERNEL]->yield(vndbid => $_ => $_[ARG1] => 1) for (@{$_[HEAP]{notify}});
$_[KERNEL]->post(core => finish => $_[ARG0]);
}
diff --git a/lib/Multi/Image.pm b/lib/Multi/Image.pm
index 4e4e6a48..fb712afd 100644
--- a/lib/Multi/Image.pm
+++ b/lib/Multi/Image.pm
@@ -95,8 +95,6 @@ sub cv_process { # id
sub cv_update { # id
if($Multi::SQL->do('UPDATE vn_rev SET image = ? WHERE image = ?', undef, $_[ARG0], -1*$_[ARG0]) > 0) {
$_[KERNEL]->yield(cv_finish => $_[ARG0]);
- } elsif(!$_[ARG1]) {
- $_[KERNEL]->delay(cv_update => 3 => $_[ARG0], 1);
} else {
$_[KERNEL]->call(core => log => 1, 'Image %d not present in the database!', $_[ARG0]);
$_[KERNEL]->yield(cv_finish => $_[ARG0]);
@@ -160,7 +158,7 @@ sub scr_process { # id
my $im = Image::Magick->new;
$im->Read($sf);
$im->Set(magick => 'JPEG');
- $im->Set(quality => 80);
+ $im->Set(quality => 90);
$im->Write($sf);
# create thumbnail
@@ -196,8 +194,6 @@ sub scr_process { # id
sub scr_update { # id, width, height
if($Multi::SQL->do('UPDATE screenshots SET status = 1, width = ?, height = ? WHERE id = ?', undef, $_[ARG1], $_[ARG2], $_[ARG0]) > 0) {
$_[KERNEL]->yield(scr_finish => $_[ARG0]);
- } elsif(!$_[ARG3]) {
- $_[KERNEL]->delay(scr_update => 3 => @_[ARG0..$#_], 1);
} else {
$_[KERNEL]->call(core => log => 1, 'Screenshot %d not present in the database!', $_[ARG0]);
$_[KERNEL]->yield(scr_finish => $_[ARG0]);
diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm
index 141aca34..8c45014a 100644
--- a/lib/Multi/RG.pm
+++ b/lib/Multi/RG.pm
@@ -25,7 +25,6 @@ sub spawn {
font => 'Arial',
fsize => [ 9, 7, 10 ], # nodes, edges, node_title
imgdir => '/www/vndb/static/rg',
- datdir => '/www/vndb/data/rg',
moy => [qw| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec |],
dot => '/usr/bin/dot',
@_,
diff --git a/lib/VNDB.pm b/lib/VNDB.pm
index 441175cb..810644a2 100644
--- a/lib/VNDB.pm
+++ b/lib/VNDB.pm
@@ -187,6 +187,7 @@ sub new {
%args,
_DB => VNDB::Util::DB->new(@VNDB::DBLOGIN),
_TPL => VNDB::Util::Template->new(%{$args{tplopts}}),
+ cmds => [],
}, $type;
return $me;
@@ -206,6 +207,10 @@ sub get_page {
my $res = $self->ResSetModPerl($r);
$self->DBCommit();
+ # commands have to be executed _after_ the call to DBCommit,
+ # otherwise Multi can't see the new additions
+ $self->RunCmd();
+
return($self, $res);
}
diff --git a/lib/VNDB/Util/Tools.pm b/lib/VNDB/Util/Tools.pm
index caa66ef4..9579e2c9 100644
--- a/lib/VNDB/Util/Tools.pm
+++ b/lib/VNDB/Util/Tools.pm
@@ -151,12 +151,19 @@ sub AddDefaultStuff {
}
+# commands aren't actually sent until the function is called without cmd parameter
sub RunCmd { # cmd
- my $s = tie my %s, 'Tie::ShareLite', @VNDB::SHMOPTS;
- $s->lock(LOCK_EX);
- my @q = ( ($s{queue} ? @{$s{queue}} : ()), $_[1] );
- $s{queue} = \@q;
- $s->unlock();
+ my($self, $c) = @_;
+ if($c) {
+ push @{$self->{cmds}}, $c;
+ } else {
+ my $s = tie my %s, 'Tie::ShareLite', @VNDB::SHMOPTS;
+ $s->lock(LOCK_EX);
+ my @q = ( ($s{queue} ? @{$s{queue}} : ()), @{$self->{cmds}} );
+ $s{queue} = \@q;
+ $s->unlock();
+ $self->{cmds} = [];
+ }
}