Merge pull request #563 from lbryio/fix-File-errors
fix: handled async File data function
This commit is contained in:
commit
2720c00cf5
2 changed files with 7 additions and 2 deletions
|
@ -24,10 +24,15 @@ const claimGet = ({ ip, originalUrl, params }, res) => {
|
|||
return getClaim(`${name}#${claimId}`);
|
||||
})
|
||||
.then(result => {
|
||||
if (!result) {
|
||||
throw new Error(`Unable to Get ${name}#${claimId}`);
|
||||
}
|
||||
getResult = result;
|
||||
})
|
||||
.then(() => {
|
||||
const fileData = createFileRecordDataAfterGet(resolveResult, getResult);
|
||||
return createFileRecordDataAfterGet(resolveResult, getResult);
|
||||
})
|
||||
.then(fileData => {
|
||||
const upsertCriteria = { name, claimId };
|
||||
return db.upsert(db.File, fileData, upsertCriteria, 'File');
|
||||
})
|
||||
|
|
|
@ -61,7 +61,7 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
|
|||
}
|
||||
if (error === NO_FILE) {
|
||||
logger.debug('no file available');
|
||||
return res.status(307).redirect(`/api/claim/get/${name}/${claimId}`);
|
||||
return res.status(307).redirect(`/api/claim/get/${claimName}/${claimId}`);
|
||||
}
|
||||
handleErrorResponse(originalUrl, ip, error, res);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue