diff --git a/routes/api-routes.js b/routes/api-routes.js index 0127e0e7..95488c57 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -72,12 +72,19 @@ module.exports = (app) => { return Promise.all([fileData, getClaim(`${params.name}#${params.claimId}`)]); }) .then(([ fileData, getResult ]) => { + if (getResult.completed !== true) { + return Promise.all([null, getResult]); // pass get results to next function + } fileData = addGetResultsToFileData(fileData, getResult); - return Promise.all([db.File.create(fileData), getResult]); // insert a record for the claim into the File table + return Promise.all([db.File.create(fileData), getResult]); // note: make this 'upsert' ? }) .then(([ fileRecord, {message, completed} ]) => { res.status(200).json({ status: 'success', message, completed }); - logger.debug('File record successfully created'); + if (fileRecord) { + logger.debug('File record successfully created'); + } else { + logger.debug('No file record created'); + } }) .catch(error => { errorHandlers.handleApiError('get', originalUrl, ip, error, res); diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 76836245..66e57c3e 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,7 +1,6 @@
-