Skip to content

Commit

Permalink
fix(bot): fix unmounting bot before writing files when overwriting (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentlp committed Feb 1, 2022
1 parent bb3e132 commit ea97ccb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/bp/src/core/bots/bot-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ import glob from 'glob'
import { inject, injectable, postConstruct, tagged } from 'inversify'
import Joi from 'joi'
import _ from 'lodash'
import mkdirp from 'mkdirp'
import moment from 'moment'
import ms from 'ms'
import { studioActions } from 'orchestrator'
import os from 'os'
import path from 'path'
import replace from 'replace-in-file'
import semver from 'semver'
import tmp from 'tmp'
import { VError } from 'verror'

Expand Down Expand Up @@ -289,9 +287,14 @@ export class BotService {
})

const folder = await this._validateBotArchive(tmpDir.name)

if (await this.botExists(botId)) {
await this.unmountBot(botId)
}

await this.ghostService.forBot(botId).importFromDirectory(folder)
const originalConfig = await this.configProvider.getBotConfig(botId)

const originalConfig = await this.configProvider.getBotConfig(botId)
const newConfigs = <Partial<BotConfig>>{
id: botId,
name: botId === originalConfig.name ? originalConfig.name : `${originalConfig.name} (${botId})`,
Expand All @@ -303,10 +306,6 @@ export class BotService {
}
}
}
if (await this.botExists(botId)) {
await this.unmountBot(botId)
}

await this.configProvider.mergeBotConfig(botId, newConfigs, true)

await this.workspaceService.addBotRef(botId, workspaceId)
Expand Down

0 comments on commit ea97ccb

Please sign in to comment.