diff --git a/routes/api-routes.js b/routes/api-routes.js index 95488c57..0127e0e7 100644 --- a/routes/api-routes.js +++ b/routes/api-routes.js @@ -72,19 +72,12 @@ 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]); // note: make this 'upsert' ? + return Promise.all([db.File.create(fileData), getResult]); // insert a record for the claim into the File table }) .then(([ fileRecord, {message, completed} ]) => { res.status(200).json({ status: 'success', message, completed }); - if (fileRecord) { - logger.debug('File record successfully created'); - } else { - logger.debug('No file record created'); - } + logger.debug('File record successfully created'); }) .catch(error => { errorHandlers.handleApiError('get', originalUrl, ip, error, res); diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 66e57c3e..4a820cdc 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -116,33 +116,6 @@ // Initiate a multipart/form-data upload xhr.send(); }, - checkIfAssetIsFullyDownloaded: function(claimName, claimId) { - // make a get request, and see fi the asset is fully downloaded. - console.log(`getting ${claimName}#${claimId}`) - var uri = `/api/get_claim/${claimName}/${claimId}`; - var xhr = new XMLHttpRequest(); - var that = this; - xhr.open("GET", uri, true); - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { - const response = JSON.parse(xhr.response); - if (xhr.status == 200) { - console.log('get returned successfully', response); - if (response.completed === true) { - console.log('lbrynet has finished downloading the asset'); - } else { - console.log('lbrynet has not finished downloading the asset'); - setTimeout(that.checkIfAssetIsFullyDownloaded.bind(that, claimName, claimId), 5000); - } - } else { - console.log('get failed:', response); - } - } else { - console.log('xhr.readyState', xhr.readyState); - } - }; - xhr.send(); - } } getAssetFunctions.checkClaimAvailability('{{claimInfo.name}}', '{{claimInfo.claimId}}');