Skip to content

Commit 4c9fa2b

Browse files
committed
Code scanning error fix
1 parent 1274133 commit 4c9fa2b

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

packages/backend/src/index.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ export function broadcastToClients(message: string) {
3939
})
4040
}
4141

42+
function serveVideo(sessionId: string, reply: any) {
43+
const videoPath = videoRegistry.get(sessionId)
44+
if (!videoPath) {
45+
return reply.code(404).send({ error: 'Video not found' })
46+
}
47+
if (!fs.existsSync(videoPath)) {
48+
return reply.code(404).send({ error: 'Video file missing from disk' })
49+
}
50+
return reply
51+
.header('Content-Type', 'video/webm')
52+
.send(fs.createReadStream(videoPath))
53+
}
54+
4255
export async function start(
4356
opts: DevtoolsBackendOptions = {}
4457
): Promise<{ server: FastifyInstance; port: number }> {
@@ -188,16 +201,7 @@ export async function start(
188201
reply
189202
) => {
190203
const { sessionId } = request.params
191-
const videoPath = videoRegistry.get(sessionId)
192-
if (!videoPath) {
193-
return reply.code(404).send({ error: 'Video not found' })
194-
}
195-
if (!fs.existsSync(videoPath)) {
196-
return reply.code(404).send({ error: 'Video file missing from disk' })
197-
}
198-
return reply
199-
.header('Content-Type', 'video/webm')
200-
.send(fs.createReadStream(videoPath))
204+
return serveVideo(sessionId, reply)
201205
}
202206
)
203207

0 commit comments

Comments
 (0)