From 759965165ff149d3aa3d3852358a431f21869a80 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 16 Oct 2014 22:06:56 +0200 Subject: [PATCH] Simplify purge_rooms --- vroom.pl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vroom.pl b/vroom.pl index 6fdfe8d..dcb37de 100755 --- a/vroom.pl +++ b/vroom.pl @@ -510,11 +510,11 @@ helper purge_rooms => sub { AND `persistent`=\'0\' AND `owner_password` IS NULL'); }; if ($@){ - return {msg => $@}; + return 0; } $sth->execute; if ($sth->err){ - return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; + return 0; } my $toDelete = {}; while (my ($room,$ether_group) = $sth->fetchrow_array){ @@ -528,11 +528,11 @@ helper purge_rooms => sub { AND `persistent`=\'0\' AND `owner_password` IS NOT NULL') }; if ($@){ - return {msg => $@}; + return 0; } $sth->execute; if ($sth->err){ - return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; + return 0; } while (my ($room, $ether_group) = $sth->fetchrow_array){ $toDelete->{$room} = $ether_group; @@ -553,17 +553,17 @@ helper purge_rooms => sub { WHERE `name` IN (" . join( ",", map { "?" } keys %{$toDelete} ) . ")"); }; if ($@){ - return {msg => $@}; + return 0; } $sth->execute(keys %{$toDelete}); if ($sth->err){ - return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; + return 0; } } else{ $self->app->log->debug('No rooms deleted, as none has expired'); } - return {ok => 1}; + return 1; }; # delete just a specific room