From d86e060d9b85397e2e961afd65a438b05de15daa Mon Sep 17 00:00:00 2001 From: Dayoung Lee Date: Thu, 5 Oct 2023 11:03:31 +0900 Subject: [PATCH] Reinforce insert function ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee --- src/OneExplorer/OneStorage.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/OneExplorer/OneStorage.ts b/src/OneExplorer/OneStorage.ts index c0d25151..b0665772 100644 --- a/src/OneExplorer/OneStorage.ts +++ b/src/OneExplorer/OneStorage.ts @@ -55,6 +55,11 @@ class CfgToCfgObjMap { return this._map.get(path); } + public set(path: string, cfgObj: ConfigObj) { + this.map.set(path, cfgObj); + } + + // TODO Revisit here public reset(type: NodeType, path: string) { switch (type) { case NodeType.config: @@ -230,10 +235,16 @@ export class OneStorage { } public static insert(node: Node) { - // NOTE - // Only _nodeMap is built by calling this function - // _baseModelToCfgsMap and _cfgToCfgObjMap are built at constructors - OneStorage.get()._nodeMap.set(node.path, node); + const inst = OneStorage.get(); + inst._nodeMap.set(node.path, node); + if (node.type === NodeType.config) { + if (!inst._cfgToCfgObjMap.get(node.path)) { + const cfgObj = ConfigObj.createConfigObj(node.uri); + if (cfgObj) { + inst._cfgToCfgObjMap.set(node.path, cfgObj); + } + } + } } /**