Files

14 lines
520 B
JavaScript

export async function cachedLoras({read,write,live,fresh: _fresh=false}) {
const cached=read() || {image:[],video:[]};
try {
// Always live-scan. Disk is asleep/empty fallback only — never a stale snapshot that skips Comfy.
const listed=await live();
const image=Array.isArray(listed?.image)?listed.image:[];
const video=Array.isArray(listed?.video)?listed.video:[];
if (!image.length && !video.length) return cached;
const next={image,video};
write(next);
return next;
} catch { return cached; }
}