mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +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'
|
||||
fromUrl: string
|
||||
contentType: string
|
||||
size?: number
|
||||
resultVariable?: string
|
||||
}
|
||||
|
||||
@ -142,12 +141,14 @@ export class WorkspaceInitializer {
|
||||
const id = uuid()
|
||||
const resp = await fetch(step.fromUrl)
|
||||
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) {
|
||||
vars[step.resultVariable] = id
|
||||
vars[`${step.resultVariable}_size`] = buffer.length
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Upload failed', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +298,9 @@ export class WorkspaceInitializer {
|
||||
const matched = fieldRegexp.exec(value)
|
||||
if (matched === null) break
|
||||
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)
|
||||
fieldRegexp.lastIndex = 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user