MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / writeMigratedDoc

Function writeMigratedDoc

projects/openade-module/src/nodeYjsStorage.ts:124–135  ·  view source on GitHub ↗
(id: string, data: Uint8Array)

Source from the content-addressed store, hash-verified

122 const ensureRoot = () => fs.mkdir(rootDir, { recursive: true })
123
124 async function writeMigratedDoc(id: string, data: Uint8Array): Promise<void> {
125 await ensureRoot()
126 const filePath = docPath(id)
127 const tempPath = `${filePath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`
128 try {
129 await fs.writeFile(tempPath, data)
130 await fs.rename(tempPath, filePath)
131 } catch (error) {
132 await fs.unlink(tempPath).catch(() => undefined)
133 throw error
134 }
135 }
136
137 async function readLegacyUpdate(id: string): Promise<Uint8Array | null> {
138 const filePath = legacyDocPath(id)

Callers 1

readUpdateFunction · 0.70

Calls 3

ensureRootFunction · 0.85
docPathFunction · 0.85
writeFileMethod · 0.80

Tested by

no test coverage detected