From e436c6e896e3d0f1e1a4cdc6274644c91eaa1f79 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 13 Sep 2023 21:02:33 -0300 Subject: [PATCH] fix(kb.gbapp): Fix importing packages. --- packages/core.gbapp/services/GBDeployer.ts | 16 ++++++++++++++++ packages/kb.gbapp/services/KBService.ts | 5 ++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/core.gbapp/services/GBDeployer.ts b/packages/core.gbapp/services/GBDeployer.ts index 9c7c5422..bd2d3836 100644 --- a/packages/core.gbapp/services/GBDeployer.ts +++ b/packages/core.gbapp/services/GBDeployer.ts @@ -662,6 +662,22 @@ export class GBDeployer implements IGBDeployer { } } + + /** + * Removes the package from the storage and local work folders. + */ + public async undeployPackageFromPackageName(instance: IGBInstance, packageName: string) { + // Gets information about the package. + + const packageType = Path.extname(packageName); + const p = await this.getStoragePackageByName(instance.instanceId, packageName); + + const path = DialogKeywords.getGBAIPath(instance.botId, null, packageName); + const localFolder = Path.join('work', path); + + return await this.undeployPackageFromLocalPath(instance, localFolder); + } + /** * Removes the package from the storage and local work folders. */ diff --git a/packages/kb.gbapp/services/KBService.ts b/packages/kb.gbapp/services/KBService.ts index 705f731b..9ac3936b 100644 --- a/packages/kb.gbapp/services/KBService.ts +++ b/packages/kb.gbapp/services/KBService.ts @@ -1019,9 +1019,8 @@ export class KBService implements IGBKBService { const packageName = Path.basename(localPath); const instance = await core.loadInstanceByBotId(min.botId); GBLog.info(`[GBDeployer] Importing: ${localPath}`); - - await deployer.undeployPackageFromLocalPath(instance, localPath); - + + await deployer['undeployPackageFromPackageName'](instance, packageName); const p = await deployer.deployPackageToStorage(instance.instanceId, packageName); await this.importKbPackage(min, localPath, p, instance); GBDeployer.mountGBKBAssets(packageName, min.botId, localPath);