(tag: string)
| 400 | } |
| 401 | |
| 402 | async checkpointExists(tag: string): Promise<boolean> { |
| 403 | if (!this.initialized) { |
| 404 | throw new Error( |
| 405 | 'Logger not initialized. Cannot check for checkpoint existence.', |
| 406 | ); |
| 407 | } |
| 408 | let filePath: string | undefined; |
| 409 | try { |
| 410 | filePath = await this._getCheckpointPath(tag); |
| 411 | // We need to check for existence again, because _getCheckpointPath |
| 412 | // returns a canonical path even if it doesn't exist yet. |
| 413 | await fs.access(filePath); |
| 414 | return true; |
| 415 | } catch (error) { |
| 416 | const nodeError = error as NodeJS.ErrnoException; |
| 417 | if (nodeError.code === 'ENOENT') { |
| 418 | return false; // It truly doesn't exist in either format. |
| 419 | } |
| 420 | // A different error occurred. |
| 421 | console.error( |
| 422 | `Failed to check checkpoint existence for ${ |
| 423 | filePath ?? `path for tag "${tag}"` |
| 424 | }:`, |
| 425 | error, |
| 426 | ); |
| 427 | throw error; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | close(): void { |
| 432 | this.initialized = false; |
no test coverage detected