MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / saveNow

Method saveNow

frontend/src/cache.ts:190–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

188 }
189
190 private async saveNow() {
191 if (!this.cachePath) return;
192
193 try {
194 // Create snapshot to avoid race condition with concurrent modifications
195 // Deep clone ensures mutations during async write don't corrupt saved data
196 const snapshot: CacheFile = {
197 version: CACHE_VERSION,
198 files: JSON.parse(JSON.stringify(this.files)),
199 crossFileEdges: JSON.parse(JSON.stringify(this.crossFileEdges)),
200 workflows: JSON.parse(JSON.stringify(this.workflows))
201 };
202 const cacheContent = JSON.stringify(snapshot, null, 2);
203 await vscode.workspace.fs.writeFile(this.cachePath, Buffer.from(cacheContent, 'utf8'));
204 this.lastSaveTime = Date.now();
205 } catch (error) {
206 console.error('Failed to save cache:', error);
207 }
208 }
209
210 /**
211 * Write the merged graph to a standalone JSON file for external consumers (e.g., MCP server).

Callers 3

scheduleSaveMethod · 0.95
flushMethod · 0.95
clearMethod · 0.95

Calls 2

parseMethod · 0.80
fromMethod · 0.45

Tested by

no test coverage detected