MCPcopy Create free account
hub / github.com/cloudflare/computer / openWriteBufferSync

Function openWriteBufferSync

packages/dofs/src/fs/writeFile.ts:521–541  ·  view source on GitHub ↗
(db: Database, path: string)

Source from the content-addressed store, hash-verified

519// buffer instead of the SQLite chunk/blob store. Release commits
520// the bytes back to chunks.
521export function openWriteBufferSync(db: Database, path: string): void {
522 const { path: canonical } = canonicalizePath(path);
523 const pending = getPendingWriteBufferByPath(db, canonical);
524 if (pending !== undefined) {
525 pending.openCount += 1;
526 return;
527 }
528 const { inode, mode } = resolveFileInode(db, path);
529 const existing = getWriteBuffer(db, inode);
530 if (existing !== undefined) {
531 existing.openCount += 1;
532 return;
533 }
534 setWriteBuffer(db, inode, {
535 buf: new Uint8Array(0),
536 size: 0,
537 dirty: false,
538 openCount: 1,
539 mode,
540 });
541}
542
543// Create a new file lazily: stash a pending-create write buffer
544// keyed by path, without touching SQL until release. createFileSync

Callers 1

Calls 5

canonicalizePathFunction · 0.85
resolveFileInodeFunction · 0.85
getWriteBufferFunction · 0.85
setWriteBufferFunction · 0.85

Tested by

no test coverage detected