Server: always check commit result

pull/30/head
Chocobozzz 2017-01-11 16:22:50 +01:00
parent bf4ff8fe0b
commit dea32aacde
3 changed files with 27 additions and 14 deletions

View File

@ -171,9 +171,12 @@ function addRemoteVideo (videoToCreateData, fromPod, finalCallback) {
}
// Commit transaction
t.commit()
t.commit().asCallback(function (err) {
if (err) return finalCallback(err)
return finalCallback()
logger.info('Remote video %s inserted.', videoToCreateData.videoToCreateData.name)
return finalCallback(null)
})
})
}
@ -254,10 +257,13 @@ function updateRemoteVideo (videoAttributesToUpdate, fromPod, finalCallback) {
return finalCallback(err)
}
// Commit transaction
t.commit()
// Commit transaction
t.commit().asCallback(function (err) {
if (err) return finalCallback(err)
return finalCallback()
logger.info('Remote video %s updated', videoAttributesToUpdate.name)
return finalCallback(null)
})
})
}

View File

@ -231,11 +231,12 @@ function addVideo (req, res, videoFile, callback) {
}
// Commit transaction
t.commit()
t.commit().asCallback(function (err) {
if (err) return callback(err)
logger.info('Video with name %s created.', videoInfos.name)
return callback(null)
logger.info('Video with name %s created.', videoInfos.name)
return callback(null)
})
})
}
@ -324,9 +325,12 @@ function updateVideo (req, res, finalCallback) {
}
// Commit transaction
t.commit()
t.commit().asCallback(function (err) {
if (err) return finalCallback(err)
return finalCallback(null)
logger.info('Video with name %s updated.', videoInfosToUpdate.name)
return finalCallback(null)
})
})
}
@ -442,9 +446,12 @@ function reportVideoAbuse (req, res, finalCallback) {
}
// Commit transaction
t.commit()
t.commit().asCallback(function (err) {
if (err) return finalCallback(err)
return finalCallback(null)
logger.info('Abuse report for video %s created.', videoInstance.name)
return finalCallback(null)
})
})
}

View File

@ -91,7 +91,7 @@ function executeMigration (actualVersion, entity, callback) {
return callback(err)
}
t.commit()
t.commit().asCallback(callback)
})
})
})