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

Function readUpdate

projects/openade-module/src/nodeYjsStorage.ts:149–172  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

147 }
148
149 async function readUpdate(id: string): Promise<Uint8Array | null> {
150 try {
151 const data = new Uint8Array(await fs.readFile(docPath(id)))
152 if (isExpectedTaskDoc(id, data)) return data
153
154 const legacyData = await readLegacyUpdate(id)
155 if (legacyData) {
156 await writeMigratedDoc(id, legacyData)
157 return legacyData
158 }
159
160 return data
161 } catch (error) {
162 if ((error as NodeJS.ErrnoException).code === "ENOENT") {
163 const legacyData = await readLegacyUpdate(id)
164 if (legacyData) {
165 await writeMigratedDoc(id, legacyData)
166 return legacyData
167 }
168 return null
169 }
170 throw error
171 }
172 }
173
174 async function saveUpdate(id: string, data: Uint8Array): Promise<void> {
175 const previous = saveQueues.get(id) ?? Promise.resolve()

Callers 3

saveUpdateFunction · 0.85
loadDocFunction · 0.85
readDocumentBase64Function · 0.85

Calls 5

docPathFunction · 0.85
readLegacyUpdateFunction · 0.85
readFileMethod · 0.80
isExpectedTaskDocFunction · 0.70
writeMigratedDocFunction · 0.70

Tested by

no test coverage detected