Simplify purge_rooms

master
Daniel Berteaud 10 years ago
parent a6dc7c9ce5
commit 759965165f
  1. 14
      vroom.pl

@ -510,11 +510,11 @@ helper purge_rooms => sub {
AND `persistent`=\'0\' AND `owner_password` IS NULL'); AND `persistent`=\'0\' AND `owner_password` IS NULL');
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute; $sth->execute;
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
my $toDelete = {}; my $toDelete = {};
while (my ($room,$ether_group) = $sth->fetchrow_array){ 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') AND `persistent`=\'0\' AND `owner_password` IS NOT NULL')
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute; $sth->execute;
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
while (my ($room, $ether_group) = $sth->fetchrow_array){ while (my ($room, $ether_group) = $sth->fetchrow_array){
$toDelete->{$room} = $ether_group; $toDelete->{$room} = $ether_group;
@ -553,17 +553,17 @@ helper purge_rooms => sub {
WHERE `name` IN (" . join( ",", map { "?" } keys %{$toDelete} ) . ")"); WHERE `name` IN (" . join( ",", map { "?" } keys %{$toDelete} ) . ")");
}; };
if ($@){ if ($@){
return {msg => $@}; return 0;
} }
$sth->execute(keys %{$toDelete}); $sth->execute(keys %{$toDelete});
if ($sth->err){ if ($sth->err){
return {msg => "DB Error: " . $sth->errstr . " (code " . $sth->err . ")"}; return 0;
} }
} }
else{ else{
$self->app->log->debug('No rooms deleted, as none has expired'); $self->app->log->debug('No rooms deleted, as none has expired');
} }
return {ok => 1}; return 1;
}; };
# delete just a specific room # delete just a specific room

Loading…
Cancel
Save