| 69 | } |
| 70 | |
| 71 | async readFile(pathname: string): Promise<StaticFile | null> { |
| 72 | const { staticFiles } = this.#snapshot; |
| 73 | |
| 74 | const info = staticFiles.get(pathname); |
| 75 | if (info === undefined) return null; |
| 76 | |
| 77 | const filePath = path.isAbsolute(info.filePath) |
| 78 | ? info.filePath |
| 79 | : path.join(this.root, info.filePath); |
| 80 | |
| 81 | const [stat, file] = await Promise.all([ |
| 82 | Deno.stat(filePath), |
| 83 | Deno.open(filePath), |
| 84 | ]); |
| 85 | |
| 86 | return { |
| 87 | hash: info.hash, |
| 88 | contentType: info.contentType, |
| 89 | size: stat.size, |
| 90 | readable: file.readable, |
| 91 | close: () => file.close(), |
| 92 | immutable: info.immutable, |
| 93 | }; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | export class IslandPreparer { |