Refresh Studio 2 LoRAs from live Comfy object_info on fresh=1.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-18 12:45:48 -05:00
co-authored by Cursor
parent 36d24feb9c
commit 7221b6a8cf
3 changed files with 82 additions and 23 deletions
+6 -2
View File
@@ -3,8 +3,12 @@ export async function cachedLoras({read,write,live,fresh=false}) {
if (!fresh && (cached.image?.length || cached.video?.length)) return cached;
try {
const listed=await live();
const next={image:listed.image?.length?listed.image:cached.image||[],video:listed.video?.length?listed.video:cached.video||[]};
if(next.image.length || next.video.length) write(next);
const image=Array.isArray(listed?.image)?listed.image:[];
const video=Array.isArray(listed?.video)?listed.video:[];
// Comfy asleep / empty: keep disk. Otherwise replace — never merge stale names that freeze adds.
if (!image.length && !video.length) return cached;
const next={image,video};
write(next);
return next;
} catch { return cached; }
}