Fix: Deleting offline node without node file won't fail anymore.

This commit is contained in:
Andreas Baldeau 2016-09-09 21:51:27 +02:00
parent a9cf109992
commit 5435f95b86

View file

@ -709,25 +709,27 @@ angular.module('ffffng')
return nodeCallback(err); return nodeCallback(err);
} }
NodeService.deleteNode(node.token, function (err) { async.seq(
function (callback) {
if (node) {
return NodeService.deleteNode(node.token, callback);
}
return callback(null);
},
function (callback) {
Database.run(
'DELETE FROM node_state WHERE mac = ? AND state = ?',
[mac, 'OFFLINE'],
callback
);
}
)(function (err) {
if (err) { if (err) {
Logger.tag('nodes', 'delete-offline').error('Error deleting node ' + mac, err); Logger.tag('nodes', 'delete-offline').error('Error deleting node ' + mac, err);
return nodeCallback(err); return nodeCallback(err);
} }
Database.run(
'DELETE FROM node_state WHERE mac = ? AND state = ?',
[mac, 'OFFLINE'],
function (err) {
if (err) {
Logger
.tag('nodes', 'delete-offline')
.error('Error deleting monitoring data for node ' + mac, err);
return nodeCallback(err);
}
nodeCallback(null); nodeCallback(null);
}
);
}); });
}); });
}, },