should be die, not return, to abort txn_do

This commit is contained in:
Oliver Gorwits
2015-04-27 08:34:28 +01:00
parent e32814222a
commit 55acc3533f
2 changed files with 6 additions and 5 deletions

View File

@@ -82,7 +82,7 @@ sub set_canonical_ip {
} }
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
$device->renumber($new_ip) or return; $device->renumber($new_ip) or die; # rollback
my $hostname = hostname_from_ip($device->ip); my $hostname = hostname_from_ip($device->ip);
$device->update({dns => $hostname}); $device->update({dns => $hostname});

View File

@@ -83,6 +83,10 @@ sub delete_device {
my $happy = 0; my $happy = 0;
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
# will delete everything related too...
schema('netdisco')->resultset('Device')
->search({ ip => $device->ip })->delete({archive_nodes => $archive});
schema('netdisco')->resultset('UserLog')->create({ schema('netdisco')->resultset('UserLog')->create({
username => session('logged_in_user'), username => session('logged_in_user'),
userip => scalar eval {request->remote_address}, userip => scalar eval {request->remote_address},
@@ -90,9 +94,6 @@ sub delete_device {
details => $log, details => $log,
}); });
# will delete everything related too...
schema('netdisco')->resultset('Device')
->search({ ip => $device->ip })->delete({archive_nodes => $archive});
$happy = 1; $happy = 1;
}); });
@@ -116,7 +117,7 @@ sub renumber_device {
my $happy = 0; my $happy = 0;
schema('netdisco')->txn_do(sub { schema('netdisco')->txn_do(sub {
$device->renumber($new_ip) or return; $device->renumber($new_ip) or die; # rollback
schema('netdisco')->resultset('UserLog')->create({ schema('netdisco')->resultset('UserLog')->create({
username => session('logged_in_user'), username => session('logged_in_user'),