Delete library stills from disk before the catalog write, and stop caching their media.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { existsSync, createReadStream } from 'node:fs'
|
||||
import { clipFrameThumbFile, ensureClipLastFrame, ensureScaledThumb, fileEtag, sniffImageType } from '~/server/utils/library'
|
||||
import { clipFrameThumbFile, ensureClipLastFrame, ensureScaledThumb, setLibraryMediaHeaders, sniffImageType } from '~/server/utils/library'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
setLibraryMediaHeaders(event)
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const clip = getClip(owner, id)
|
||||
@@ -25,13 +26,6 @@ export default defineEventHandler(async (event) => {
|
||||
if (thumbPath && existsSync(thumbPath)) path = thumbPath
|
||||
}
|
||||
|
||||
const etag = fileEtag(path)
|
||||
setHeader(event, 'ETag', etag)
|
||||
setHeader(event, 'Cache-Control', wantThumb ? 'private, max-age=60, must-revalidate' : 'private, max-age=60, must-revalidate')
|
||||
if (getHeader(event, 'if-none-match') === etag) {
|
||||
setResponseStatus(event, 304)
|
||||
return null
|
||||
}
|
||||
setHeader(event, 'Content-Type', wantThumb && path !== framePath ? 'image/jpeg' : sniffImageType(path))
|
||||
return sendStream(event, createReadStream(path))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user