Add paginated library JSON and dedicated still thumbs that never stream archive masters.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-29 19:45:22 -05:00
co-authored by Cursor
parent 845ee5bbf6
commit aa0aa871e4
10 changed files with 315 additions and 37 deletions
@@ -0,0 +1,26 @@
import { existsSync, createReadStream } from 'node:fs'
import { fileEtag, stillPath, stillThumbPath } from '~/server/utils/library'
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 = await stillThumbPath(owner, id)
const original = stillPath(owner, still.id)
// Never stream the archive master as a "thumb"
if (!path || !existsSync(path) || path === original) {
throw createError({ statusCode: 404, statusMessage: 'Thumbnail not found' })
}
const etag = fileEtag(path)
setHeader(event, 'ETag', etag)
setHeader(event, 'Cache-Control', 'public, max-age=86400')
if (getHeader(event, 'if-none-match') === etag) {
setResponseStatus(event, 304)
return null
}
setHeader(event, 'Content-Type', 'image/jpeg')
return sendStream(event, createReadStream(path))
})