(filePath: string, data: string)
| 693 | } |
| 694 | |
| 695 | private async appendToFile(filePath: string, data: string): Promise<boolean> { |
| 696 | if (this.persistenceUnavailable) { |
| 697 | return false |
| 698 | } |
| 699 | try { |
| 700 | await fsAppendFile(filePath, data, { mode: 0o600 }) |
| 701 | return true |
| 702 | } catch (error) { |
| 703 | if (this.disablePersistenceForError(error, `append ${filePath}`)) { |
| 704 | return false |
| 705 | } |
| 706 | // Directory may not exist — some NFS-like filesystems return |
| 707 | // unexpected error codes, so don't discriminate on code. |
| 708 | try { |
| 709 | await mkdir(dirname(filePath), { recursive: true, mode: 0o700 }) |
| 710 | await fsAppendFile(filePath, data, { mode: 0o600 }) |
| 711 | return true |
| 712 | } catch (retryError) { |
| 713 | if ( |
| 714 | this.disablePersistenceForError( |
| 715 | retryError, |
| 716 | `append retry ${filePath}`, |
| 717 | ) |
| 718 | ) { |
| 719 | return false |
| 720 | } |
| 721 | throw retryError |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | private async drainWriteQueue(): Promise<void> { |
| 727 | for (const [filePath, queue] of this.writeQueues) { |
no test coverage detected