From 4a4cdb23f74799b245f684309ec1f78a3c0d6b1e Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 29 Nov 2017 11:56:09 -0800 Subject: [PATCH] added loop to check if asset is fully downloaded; --- routes/api-routes.js | 11 +++++++-- views/partials/asset.handlebars | 43 +++++++++++++++++++++------------ 2 files changed, 37 insertions(+), 17 deletions(-) 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 @@
-