summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-08-14 21:52:54 +0000
committeryorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b>2008-08-14 21:52:54 +0000
commit1c71b23985ace088dd8fa01001521c3844a14c40 (patch)
tree405b8c675cd38f4a299fda20f136d6912d34291e
parent2cf1c1848571f11e753dec784c7323e51b00801d (diff)
Fixed bug with an edit being comitted without any changes, renamed anime check command and added small but useful note to multi.pl
git-svn-id: svn://vndb.org/vndb@85 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
-rw-r--r--lib/ChangeLog1
-rw-r--r--lib/Multi/Anime.pm8
-rw-r--r--lib/VNDB/VN.pm15
-rw-r--r--util/multi.pl3
4 files changed, 16 insertions, 11 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 688629d7..bb5ef924 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -11,6 +11,7 @@ TODO:
- Added realtime IRC notifications for actions on the site
- Added screenshots to VNs
- Rewrote Multi::Image
+ - Renamed the 'anime check' command to 'anime' for consistency
1.20 - 2008-08-06 (r79)
- Admins can change someone's username
diff --git a/lib/Multi/Anime.pm b/lib/Multi/Anime.pm
index 6f329bd5..42bd52bf 100644
--- a/lib/Multi/Anime.pm
+++ b/lib/Multi/Anime.pm
@@ -36,7 +36,7 @@ sub spawn {
# This module -only- fetches anime information in daemon mode!
# Calling the anime command with an ID as argument will force
# the information to be refreshed. This is not recommended,
- # just use 'anime check' for normal usage.
+ # just use 'anime' for normal usage.
my $p = shift;
POE::Session->create(
@@ -81,10 +81,10 @@ sub spawn {
sub _start {
$_[KERNEL]->alias_set('anime');
- $_[KERNEL]->call(core => register => qr/^anime ([0-9]+|check)$/, 'cmd_anime');
+ $_[KERNEL]->call(core => register => qr/^anime(?: ([0-9]+))?$/, 'cmd_anime');
# check for anime twice a day
- $_[KERNEL]->post(core => addcron => '0 0,12 * * *', 'anime check');
+ $_[KERNEL]->post(core => addcron => '0 0,12 * * *', 'anime');
$_[KERNEL]->sig('shutdown' => 'shutdown');
if(!$Multi::DAEMONIZE) {
@@ -110,7 +110,7 @@ sub shutdown {
sub cmd_anime { # cmd, arg
my @push;
- if($_[ARG1] eq 'check') {
+ if(!$_[ARG1]) {
# only animes we have never fetched, or haven't been updated for a month
my $q = $Multi::SQL->prepare(q|
SELECT id
diff --git a/lib/VNDB/VN.pm b/lib/VNDB/VN.pm
index e52fc2fc..666349f7 100644
--- a/lib/VNDB/VN.pm
+++ b/lib/VNDB/VN.pm
@@ -105,17 +105,18 @@ sub VNEdit {
{ name => 'screenshots', required => 0, default => '' },
{ name => 'comm', required => 0, default => '' },
);
+ my $relations = [ map { /^([0-9]+),([0-9]+)/ && $2 != $id ? ( [ $1, $2 ] ) : () } split /\|\|\|/, $frm->{relations} ];
+ my $cat = [ map { [ substr($_,0,3), substr($_,3,1) ] } split /,/, $frm->{categories} ];
+ my $anime = [ grep /^[0-9]+$/, split / +/, $frm->{anime} ];
+ my $screenshots = [ map [split /,/], grep /^[0-9]+,[01]$/, split / +/, $frm->{screenshots} ];
+
$frm->{img_nsfw} = $frm->{img_nsfw} ? 1 : 0;
- $frm->{anime} = join(' ', sort { $a <=> $b } grep /^[0-9]+$/, split(/\s+/, $frm->{anime})); # re-sort
+ $frm->{anime} = join ' ', sort { $a <=> $b } @$anime; # re-sort
+ $frm->{screenshots} = join ' ', map "$$_[0],$$_[1]", sort { $$a[0] <=> $$b[0] } @$screenshots;
return $self->ResRedirect('/v'.$id, 'post')
if $id && !$self->ReqParam('img') && 13 == scalar grep { $b4{$_} eq $frm->{$_} } keys %b4;
- my $relations = [ map { /^([0-9]+),([0-9]+)/ && $2 != $id ? ( [ $1, $2 ] ) : () } split /\|\|\|/, $frm->{relations} ];
- my $cat = [ map { [ substr($_,0,3), substr($_,3,1) ] } split /,/, $frm->{categories} ];
- my $anime = [ split / +/, $frm->{anime} ];
- my $screenshots = [ map [split /,/], grep /^[0-9]+,[01]$/, split / +/, $frm->{screenshots} ];
-
# upload image
my $imgid = 0;
if($self->ReqParam('img')) {
@@ -172,7 +173,7 @@ sub VNEdit {
}
# check for new anime data
- $self->RunCmd('anime check') if $oid && $frm->{anime} ne $b4{anime} || !$oid && $frm->{anime};
+ $self->RunCmd('anime') if $oid && $frm->{anime} ne $b4{anime} || !$oid && $frm->{anime};
$self->RunCmd('ircnotify v'.$id.'.'.$nrev);
return $self->ResRedirect('/v'.$id.'.'.$nrev, 'post');
diff --git a/util/multi.pl b/util/multi.pl
index 9a072d02..6ec3dd02 100644
--- a/util/multi.pl
+++ b/util/multi.pl
@@ -14,6 +14,9 @@
# Multi - core namespace for initialisation and global variables
#
+# NOTE: in case of errors, clearing the shared memory might work:
+# $ ipcrm -S 0x42444e56 -M 0x42444e56
+
package Multi;
use strict;