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
+16 -3
View File
@@ -7,13 +7,26 @@ export default defineEventHandler(async (event) => {
const still = getStill(owner, id)
assertFolderAccess(event, still.folderId)
const wantThumb = String(getQuery(event).thumb || '') === '1'
const path = wantThumb ? await stillThumbPath(owner, id) : stillPath(owner, still.id)
if (!path || !existsSync(path)) {
const original = stillPath(owner, still.id)
let path = original
if (wantThumb) {
path = await stillThumbPath(owner, id)
// Never fall back to the archive PNG/JPEG for ?thumb=1
if (!path || path === original || !existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'Thumbnail not found' })
}
} else if (!existsSync(path)) {
throw createError({ statusCode: 404, statusMessage: 'Image file is missing' })
}
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')
setHeader(
event,
'Cache-Control',
wantThumb ? 'public, max-age=86400' : 'private, max-age=3600'
)
if (getHeader(event, 'if-none-match') === etag) {
setResponseStatus(event, 304)
return null