Queue Generate with an immediate local card and stop blocking reload on library or object_info.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-29 19:46:55 -05:00
co-authored by Cursor
parent ffdaa7ce42
commit cfabfd37ee
3 changed files with 129 additions and 35 deletions
+4 -4
View File
@@ -1,19 +1,19 @@
import { readFileSync,writeFileSync,renameSync } from 'node:fs'
import { readFileSync, writeFileSync, renameSync } from 'node:fs'
import { join } from 'node:path'
import { cachedLoras } from '~/shared/studio2/lora-cache.mjs'
import { listStudioLoras } from '../../utils/loras'
import { studio2Root } from '../../utils/studio2/store'
import { studio2LoraCatalog } from '../../utils/studio2/lora-catalog'
export default defineEventHandler(async event => {
export default defineEventHandler(async (event) => {
const { owner } = assertLibraryOwner(event)
const path = join(studio2Root(), `loras-${owner}.cache`)
// Same live Comfy scan as Settings (/api/loras?fresh=1). Always fresh so CACHE_MS cannot freeze adds.
const fresh = String(getQuery(event).fresh || '') === '1'
const listed = await cachedLoras({
read: () => { try { return JSON.parse(readFileSync(path, 'utf8')) } catch { return null } },
write: value => { writeFileSync(path + '.tmp', JSON.stringify(value)); renameSync(path + '.tmp', path) },
live: () => listStudioLoras({ fresh: true }),
fresh: true
fresh
})
return { ...listed, ...studio2LoraCatalog(owner) }
})