mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Fix bug on order assets that was stopping the flow after paying.
This commit is contained in:
parent
c2de39769b
commit
29ea28cf90
@ -136,9 +136,17 @@ export class Brizo extends Instantiable {
|
|||||||
const response = await WebServiceConnectorProvider
|
const response = await WebServiceConnectorProvider
|
||||||
.getConnector()
|
.getConnector()
|
||||||
.get(url)
|
.get(url)
|
||||||
const filename = response.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]
|
if (!response.ok) {
|
||||||
if (destination) {
|
throw new Error("Response error.")
|
||||||
|
}
|
||||||
|
let filename
|
||||||
|
try {
|
||||||
|
filename = response.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]
|
||||||
|
} catch {
|
||||||
|
throw new Error("Response is not containing file name.")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destination) {
|
||||||
await new Promise(async (resolve, reject) => {
|
await new Promise(async (resolve, reject) => {
|
||||||
fs.mkdirSync(destination, {recursive: true})
|
fs.mkdirSync(destination, {recursive: true})
|
||||||
const fileStream = fs.createWriteStream(`${destination}${filename}`)
|
const fileStream = fs.createWriteStream(`${destination}${filename}`)
|
||||||
|
@ -227,6 +227,8 @@ export class OceanAssets extends Instantiable {
|
|||||||
|
|
||||||
this.logger.log("Locking payment")
|
this.logger.log("Locking payment")
|
||||||
|
|
||||||
|
const accessGranted = accessCondition.getConditionFulfilledEvent(agreementId).once()
|
||||||
|
|
||||||
const paid = await oceanAgreements.conditions.lockReward(agreementId, metadata.base.price, consumer)
|
const paid = await oceanAgreements.conditions.lockReward(agreementId, metadata.base.price, consumer)
|
||||||
|
|
||||||
if (paid) {
|
if (paid) {
|
||||||
@ -238,7 +240,7 @@ export class OceanAssets extends Instantiable {
|
|||||||
reject("Error on payment")
|
reject("Error on payment")
|
||||||
}
|
}
|
||||||
|
|
||||||
await accessCondition.getConditionFulfilledEvent(agreementId).once()
|
await accessGranted
|
||||||
|
|
||||||
this.logger.log("Access granted")
|
this.logger.log("Access granted")
|
||||||
resolve()
|
resolve()
|
||||||
|
Loading…
Reference in New Issue
Block a user