Fix #26 API redirects to the response before it's written to disk
This commit is contained in:
@@ -52,16 +52,25 @@ var ApiController = function(app) {
|
||||
.then(function(data) {
|
||||
|
||||
debug('Success');
|
||||
runsDatastore.markAsComplete(run.runId);
|
||||
|
||||
|
||||
// Save result in datastore
|
||||
data.runId = run.runId;
|
||||
resultsDatastore.saveResult(data);
|
||||
resultsDatastore.saveResult(data)
|
||||
.then(function() {
|
||||
|
||||
// Send result if the user was waiting
|
||||
if (run.params.waitForResponse) {
|
||||
res.redirect(302, '/api/results/' + run.runId);
|
||||
}
|
||||
runsDatastore.markAsComplete(run.runId);
|
||||
|
||||
// Send result if the user was waiting
|
||||
if (run.params.waitForResponse) {
|
||||
res.redirect(302, '/api/results/' + run.runId);
|
||||
}
|
||||
|
||||
})
|
||||
.fail(function(err) {
|
||||
debug('Saving results to resultsDatastore failed:');
|
||||
debug(err);
|
||||
});
|
||||
|
||||
}).fail(function(err) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user