| 11 | // fetchObjects on one side and pushObjects on the other. Both names |
| 12 | // resolve to the same SQL. |
| 13 | export async function* pushObjects( |
| 14 | db: Database, |
| 15 | hashes: Uint8Array[], |
| 16 | ): AsyncIterable<{ hash: Uint8Array; bytes: Uint8Array }> { |
| 17 | for (const hash of hashes) { |
| 18 | const row = db.one<{ bytes: Uint8Array }>( |
| 19 | "SELECT bytes FROM vfs_blob_bytes WHERE hash = ?", |
| 20 | hash, |
| 21 | ); |
| 22 | if (row === undefined) { |
| 23 | throw createWorkspaceError("EUNKNOWN_HASH", "pushObjects: missing blob for requested hash"); |
| 24 | } |
| 25 | yield { hash, bytes: row.bytes }; |
| 26 | } |
| 27 | } |