MCPcopy Create free account
hub / github.com/anus-dev/ANUS / _getCheckpointPath

Method _getCheckpointPath

packages/core/src/core/logger.ts:283–311  ·  view source on GitHub ↗
(tag: string)

Source from the content-addressed store, hash-verified

281 }
282
283 private async _getCheckpointPath(tag: string): Promise<string> {
284 // 1. Check for the new encoded path first.
285 const newPath = this._checkpointPath(tag);
286 try {
287 await fs.access(newPath);
288 return newPath; // Found it, use the new path.
289 } catch (error) {
290 const nodeError = error as NodeJS.ErrnoException;
291 if (nodeError.code !== 'ENOENT') {
292 throw error; // A real error occurred, rethrow it.
293 }
294 // It was not found, so we'll check the old path next.
295 }
296
297 // 2. Fallback for backward compatibility: check for the old raw path.
298 const oldPath = path.join(this.anusDir!, `checkpoint-${tag}.json`);
299 try {
300 await fs.access(oldPath);
301 return oldPath; // Found it, use the old path.
302 } catch (error) {
303 const nodeError = error as NodeJS.ErrnoException;
304 if (nodeError.code !== 'ENOENT') {
305 throw error; // A real error occurred, rethrow it.
306 }
307 }
308
309 // 3. If neither path exists, return the new encoded path as the canonical one.
310 return newPath;
311 }
312
313 async saveCheckpoint(conversation: Content[], tag: string): Promise<void> {
314 if (!this.initialized) {

Callers 2

loadCheckpointMethod · 0.95
checkpointExistsMethod · 0.95

Calls 1

_checkpointPathMethod · 0.95

Tested by

no test coverage detected