Nest shot scripts under Queue jobs, keep the studio from overflowing on phones, and lighten library thumbs and polling so the UI stays responsive.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-27 22:27:17 -05:00
co-authored by Cursor
parent dec1a49bef
commit b2c59c3423
14 changed files with 634 additions and 133 deletions
+15 -8
View File
@@ -1,16 +1,23 @@
import { existsSync, readFileSync } from 'node:fs'
import { existsSync, createReadStream } from 'node:fs'
import { fileEtag, stillPath, stillThumbPath, sniffImageType } from '~/server/utils/library'
export default defineEventHandler((event) => {
export default defineEventHandler(async (event) => {
const { owner } = assertLibraryOwner(event)
const id = String(getRouterParam(event, 'id') || '')
const still = getStill(owner, id)
assertFolderAccess(event, still.folderId)
const path = stillPath(owner, still.id)
if (!existsSync(path)) {
const wantThumb = String(getQuery(event).thumb || '') === '1'
const path = wantThumb ? await stillThumbPath(owner, id) : stillPath(owner, still.id)
if (!path || !existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'Image file is missing' })
}
const buf = readFileSync(path)
setHeader(event, 'Content-Type', imageContentType(buf))
setHeader(event, 'Cache-Control', 'private, max-age=3600')
return buf
const etag = fileEtag(path)
setHeader(event, 'ETag', etag)
setHeader(event, 'Cache-Control', wantThumb ? 'private, max-age=86400, stale-while-revalidate=604800' : 'private, max-age=3600')
if (getHeader(event, 'if-none-match') === etag) {
setResponseStatus(event, 304)
return null
}
setHeader(event, 'Content-Type', wantThumb ? 'image/jpeg' : sniffImageType(path))
return sendStream(event, createReadStream(path))
})