Merge pull request #563 from lbryio/fix-File-errors

fix: handled async File data function
This commit is contained in:
Bill Bittner 2018-08-07 12:55:24 -07:00 committed by GitHub
commit 2720c00cf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -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');
})

View 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);
});