tested with daemon and fixed handle of invalid uri
This commit is contained in:
parent
bf516c07c2
commit
af8242a3c6
1 changed files with 9 additions and 10 deletions
|
@ -198,26 +198,25 @@ module.exports = {
|
||||||
uri = `${name}#${validClaimId}`;
|
uri = `${name}#${validClaimId}`;
|
||||||
return db.File.findOne({ where: { name, claimId: validClaimId } });
|
return db.File.findOne({ where: { name, claimId: validClaimId } });
|
||||||
})
|
})
|
||||||
.then(({ dataValues }) => {
|
.then(result => {
|
||||||
if (dataValues) { // 3. if a match is found locally, serve that claim
|
// 3. if a match is found locally, serve that claim
|
||||||
logger.debug('Result found in File table:', dataValues);
|
if (result) {
|
||||||
|
logger.debug('Result found in File table:', result.dataValues);
|
||||||
// return the data for the file to be served
|
// return the data for the file to be served
|
||||||
resolve(dataValues); // break out of the chain???
|
resolve(result.dataValues);
|
||||||
// update the file, as needed
|
// update the file, as needed
|
||||||
updateFileIfNeeded(uri, name, claimId, dataValues.outpoint, dataValues.outpoint);
|
updateFileIfNeeded(uri, name, claimId, result.dataValues.outpoint, result.dataValues.outpoint);
|
||||||
// 3. if a match was not found use the daemon to retrieve the claim & return the db data once it is created
|
// 3. if a match was not found use the daemon to retrieve the claim & return the db data once it is created
|
||||||
} else { // 4. resolve the Uri
|
} else {
|
||||||
logger.debug('No result found in File table,');
|
logger.debug('No result found in File table,');
|
||||||
lbryApi
|
lbryApi
|
||||||
.resolveUri(uri)
|
.resolveUri(uri)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// check to make sure the result is a claim
|
if (!result.claim) { // check to make sure the result is a claim
|
||||||
if (!result.claim) {
|
|
||||||
logger.debug('resolve did not return a claim');
|
logger.debug('resolve did not return a claim');
|
||||||
resolve(null);
|
resolve(null);
|
||||||
}
|
}
|
||||||
// check to see if the claim is free & public
|
if (isFreePublicClaim(result.claim)) { // check to see if the claim is free & public
|
||||||
if (isFreePublicClaim(result.claim)) {
|
|
||||||
// get claim and serve
|
// get claim and serve
|
||||||
resolve(getClaimAndReturnResponse(uri, result.claim.address, result.claim.height));
|
resolve(getClaimAndReturnResponse(uri, result.claim.address, result.claim.height));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue