fixed "Cannot read property "stream" of null" on new get requests
This commit is contained in:
parent
ed9e7ffefd
commit
bcf0484b5b
1 changed files with 17 additions and 9 deletions
|
@ -20,15 +20,24 @@ function checkForLocalAssetByClaimId (claimId, name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatGetResultsToFileInfo ({ name, claim_id, outpoint, file_name, download_path, mime_type, metadata }) {
|
function addGetResultsToFileRecord (fileInfo, getResult) {
|
||||||
|
fileInfo.fileName = getResult.file_name;
|
||||||
|
fileInfo.filePath = getResult.download_path;
|
||||||
|
fileInfo.fileType = getResult.mime_type;
|
||||||
|
return fileInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createFileRecord ({ name, claimId, outpoint, height, address, nsfw }) {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
claimId : claim_id,
|
claimId,
|
||||||
outpoint,
|
outpoint,
|
||||||
fileName: file_name,
|
height,
|
||||||
filePath: download_path,
|
address,
|
||||||
fileType: mime_type,
|
fileName: '',
|
||||||
nsfw : metadata.stream.metadata.nsfw,
|
filePath: '',
|
||||||
|
fileType: '',
|
||||||
|
nsfw,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,9 +66,8 @@ function getAssetByClaimId (fullClaimId, name) {
|
||||||
lbryApi.getClaim(`${name}#${fullClaimId}`)
|
lbryApi.getClaim(`${name}#${fullClaimId}`)
|
||||||
.then(getResult => {
|
.then(getResult => {
|
||||||
logger.debug('getResult >>', getResult);
|
logger.debug('getResult >>', getResult);
|
||||||
fileRecord = formatGetResultsToFileInfo(getResult);
|
fileRecord = createFileRecord(resolveResult);
|
||||||
fileRecord['address'] = (resolveResult.address || 0);
|
fileRecord = addGetResultsToFileRecord(fileRecord, getResult);
|
||||||
fileRecord['height'] = resolveResult.height;
|
|
||||||
// insert a record in the File table & Update Claim table
|
// insert a record in the File table & Update Claim table
|
||||||
return db.File.create(fileRecord);
|
return db.File.create(fileRecord);
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue