mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 15:53:28 +02:00
Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
@@ -138,6 +138,7 @@ function addUserDevice(req, res) {
|
||||
|
||||
datautil.normalize(device, req.user)
|
||||
if (!deviceutil.isAddable(device, req.user)) {
|
||||
lockutil.unlockDevice(lock)
|
||||
return res.status(403).json({
|
||||
success: false
|
||||
, description: 'Device is being used or not available'
|
||||
@@ -147,6 +148,7 @@ function addUserDevice(req, res) {
|
||||
// Timer will be called if no JoinGroupMessage is received till 5 seconds
|
||||
var responseTimer = setTimeout(function() {
|
||||
req.options.channelRouter.removeListener(wireutil.global, messageListener)
|
||||
lockutil.unlockDevice(lock)
|
||||
return res.status(504).json({
|
||||
success: false
|
||||
, description: 'Device is not responding'
|
||||
@@ -158,6 +160,7 @@ function addUserDevice(req, res) {
|
||||
if (message.serial === serial && message.owner.email === req.user.email) {
|
||||
clearTimeout(responseTimer)
|
||||
req.options.channelRouter.removeListener(wireutil.global, messageListener)
|
||||
lockutil.unlockDevice(lock)
|
||||
|
||||
return res.json({
|
||||
success: true
|
||||
@@ -191,13 +194,10 @@ function addUserDevice(req, res) {
|
||||
)
|
||||
])
|
||||
}
|
||||
return false
|
||||
})
|
||||
.catch(function(err) {
|
||||
apiutil.internalError(res, `Failed to take control of ${serial} device: `, err.stack)
|
||||
})
|
||||
.finally(function() {
|
||||
lockutil.unlockDevice(lock)
|
||||
apiutil.internalError(res, `Failed to take control of ${serial} device: `, err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user