| 113 | } |
| 114 | |
| 115 | export async function writeFile( |
| 116 | db: Database, |
| 117 | path: string, |
| 118 | content: WriteFileContent, |
| 119 | options: WriteFileOptions, |
| 120 | now: () => number, |
| 121 | ): Promise<void> { |
| 122 | if (content instanceof ReadableStream) { |
| 123 | await writeFileStreaming(db, path, content, options, now); |
| 124 | return; |
| 125 | } |
| 126 | const bytes = await materialize(content); |
| 127 | writeFileSync(db, path, bytes, options, now); |
| 128 | } |
| 129 | |
| 130 | // Streaming write path. Reads the source one source-chunk at a time, |
| 131 | // re-windows into fixed CHUNK_SIZE pieces, hashes each window, and |