fix(kb.gbapp): Fix importing packages.

This commit is contained in:
Rodrigo Rodriguez 2023-09-14 12:02:53 -03:00
parent ac865497f0
commit e39c33b8f7
3 changed files with 11 additions and 3 deletions

View file

@ -170,7 +170,7 @@ export class GBAdminService implements IGBAdminService {
// .gbot packages are handled using storage API, so no download
// of local resources is required.
const gbai = DialogKeywords.getGBAIPath(min.instance.botId);
await deployer['undeployPackageFromPackageName'](min.instance, packageName);
await deployer['downloadFolder'](min,
Path.join('work', `${gbai}`),
Path.basename(localFolder));

View file

@ -662,7 +662,15 @@ export class GBDeployer implements IGBDeployer {
}
}
/**
* Removes the package local files from cache.
*/
public async cleanupPackage(instance: IGBInstance, packageName: string) {
const path = DialogKeywords.getGBAIPath(instance.botId, null, packageName);
const localFolder = Path.join('work', path);
rimraf.sync(localFolder);
}
/**
* Removes the package from the storage and local work folders.
*/

View file

@ -1019,7 +1019,7 @@ export class KBService implements IGBKBService {
const packageName = Path.basename(localPath);
const instance = await core.loadInstanceByBotId(min.botId);
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
await deployer['cleanupPackage'](min.instance, packageName);
const p = await deployer.deployPackageToStorage(instance.instanceId, packageName);
await this.importKbPackage(min, localPath, p, instance);
GBDeployer.mountGBKBAssets(packageName, min.botId, localPath);