mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-08 21:27:45 +03:00
Fix init script (#6105)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b92ec6b9fc
commit
5816a0dedd
@ -79,7 +79,6 @@ export interface UploadStep {
|
|||||||
type: 'upload'
|
type: 'upload'
|
||||||
fromUrl: string
|
fromUrl: string
|
||||||
contentType: string
|
contentType: string
|
||||||
size?: number
|
|
||||||
resultVariable?: string
|
resultVariable?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,12 +141,14 @@ export class WorkspaceInitializer {
|
|||||||
const id = uuid()
|
const id = uuid()
|
||||||
const resp = await fetch(step.fromUrl)
|
const resp = await fetch(step.fromUrl)
|
||||||
const buffer = Buffer.from(await resp.arrayBuffer())
|
const buffer = Buffer.from(await resp.arrayBuffer())
|
||||||
await this.storageAdapter.put(this.ctx, this.wsUrl, id, buffer, step.contentType, step.size)
|
await this.storageAdapter.put(this.ctx, this.wsUrl, id, buffer, step.contentType, buffer.length)
|
||||||
if (step.resultVariable !== undefined) {
|
if (step.resultVariable !== undefined) {
|
||||||
vars[step.resultVariable] = id
|
vars[step.resultVariable] = id
|
||||||
|
vars[`${step.resultVariable}_size`] = buffer.length
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Upload failed', error)
|
logger.error('Upload failed', error)
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +298,9 @@ export class WorkspaceInitializer {
|
|||||||
const matched = fieldRegexp.exec(value)
|
const matched = fieldRegexp.exec(value)
|
||||||
if (matched === null) break
|
if (matched === null) break
|
||||||
const result = vars[matched[0]]
|
const result = vars[matched[0]]
|
||||||
if (result !== undefined && typeof result === 'string') {
|
if (result === undefined || typeof result !== 'string') {
|
||||||
|
throw new Error(`Variable ${matched[0]} not found`)
|
||||||
|
} else {
|
||||||
value = value.replaceAll(matched[0], result)
|
value = value.replaceAll(matched[0], result)
|
||||||
fieldRegexp.lastIndex = 0
|
fieldRegexp.lastIndex = 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user