MCPcopy Create free account
hub / github.com/Noumena-Network/code / appendToFile

Method appendToFile

src/utils/sessionStorage.ts:695–724  ·  view source on GitHub ↗
(filePath: string, data: string)

Source from the content-addressed store, hash-verified

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) {

Callers 1

drainWriteQueueMethod · 0.95

Calls 2

mkdirFunction · 0.85

Tested by

no test coverage detected