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
|
||||
.getConnector()
|
||||
.get(url)
|
||||
const filename = response.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]
|
||||
if (destination) {
|
||||
if (!response.ok) {
|
||||
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) => {
|
||||
fs.mkdirSync(destination, {recursive: true})
|
||||
const fileStream = fs.createWriteStream(`${destination}${filename}`)
|
||||
|
@ -227,6 +227,8 @@ export class OceanAssets extends Instantiable {
|
||||
|
||||
this.logger.log("Locking payment")
|
||||
|
||||
const accessGranted = accessCondition.getConditionFulfilledEvent(agreementId).once()
|
||||
|
||||
const paid = await oceanAgreements.conditions.lockReward(agreementId, metadata.base.price, consumer)
|
||||
|
||||
if (paid) {
|
||||
@ -238,7 +240,7 @@ export class OceanAssets extends Instantiable {
|
||||
reject("Error on payment")
|
||||
}
|
||||
|
||||
await accessCondition.getConditionFulfilledEvent(agreementId).once()
|
||||
await accessGranted
|
||||
|
||||
this.logger.log("Access granted")
|
||||
resolve()
|
||||
|
Loading…
Reference in New Issue
Block a user