From 99413abdf6b8ed993b830965e5ac9efaa305b0f1 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Thu, 15 Jun 2017 15:56:40 -0700 Subject: [PATCH] added 'outpoint' to Files model' --- helpers/lbryApi.js | 6 ++--- helpers/socketHelpers.js | 1 + models/file.js | 50 ++++++++++++++++++++++------------------ 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/helpers/lbryApi.js b/helpers/lbryApi.js index 4d14d7d3..9bca7521 100644 --- a/helpers/lbryApi.js +++ b/helpers/lbryApi.js @@ -26,11 +26,10 @@ module.exports = { "params": { "uri": uri, "timeout": 20} }).then(function (getResponse) { console.log(">> 'get' success", getResponse.data); - //check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success response) + //check to make sure the daemon didn't just time out if (getResponse.data.result.error){ reject(getResponse.data.result.error); } - // resolve the promise with the download path for the claim we got /* note: put in a check to make sure we do not resolve until the download is actually complete (response.data.completed === true) */ @@ -40,12 +39,13 @@ module.exports = { path: getResponse.data.result.download_path, file_type: getResponse.data.result.mime_type, claim_id: getResponse.data.result.claim_id, + outpoint: getResponse.data.result.outpoint, nsfw: getResponse.data.result.metadata.stream.metadata.nsfw, }).catch(function(error){ console.log('an error occurred when writing to the MySQL database. Check the logs.'); }); // resolve the promise - resolve(getResponse.data); //to do: return the result + resolve(getResponse.data); }).catch(function(getUriError){ console.log(">> 'get' error"); // reject the promise with an error message diff --git a/helpers/socketHelpers.js b/helpers/socketHelpers.js index 3caf7042..520479dc 100644 --- a/helpers/socketHelpers.js +++ b/helpers/socketHelpers.js @@ -61,6 +61,7 @@ module.exports = { path: filePath, file_type: fileType, claim_id: data.result.claim_id, + outpoint: getResponse.data.result.outpoint, nsfw: nsfw, }).catch(function(error){ console.log('an error occurred when writing to the MySQL database. Check the logs.'); diff --git a/models/file.js b/models/file.js index c5a4dbf1..0e6bf6db 100644 --- a/models/file.js +++ b/models/file.js @@ -1,27 +1,31 @@ module.exports = function(sequelize, DataTypes){ - var File = sequelize.define("File", { - name: { - type: DataTypes.STRING, - allowNull: false, - validate: { - len: [1] - } - }, - path: { - type: DataTypes.STRING - }, - file_type: { - type: DataTypes.STRING - }, - claim_id: { - type: DataTypes.STRING - }, - nsfw: { - type: DataTypes.BOOLEAN, - defaultValue: false - } - }, { + var File = sequelize.define("File", { + name: { + type: DataTypes.STRING, + allowNull: false + }, + path: { + type: DataTypes.STRING, + allowNull: false + }, + file_type: { + type: DataTypes.STRING, + }, + claim_id: { + type: DataTypes.STRING, + allowNull: false + }, + outpoint: { + type: DataTypes.STRING, + allowNull: false + }, + nsfw: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: false + } + }, { freezeTableName: true }); - return File; + return File; } \ No newline at end of file