mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-25 06:22:14 -03:00
Add image garbage collection to canvas
Introduced ImageReferenceManager to track and clean up unused images from the database and cache. Added manual garbage collection controls to the UI and exposed related stats and cleanup methods in Canvas. Updated db.js with a method to retrieve all image IDs for cleanup purposes.
This commit is contained in:
22
js/db.js
22
js/db.js
@@ -146,6 +146,28 @@ export async function removeImage(imageId) {
|
||||
log.debug(`Remove image success for id: ${imageId}`);
|
||||
}
|
||||
|
||||
export async function getAllImageIds() {
|
||||
log.info("Getting all image IDs...");
|
||||
const db = await openDB();
|
||||
const transaction = db.transaction([IMAGE_STORE_NAME], 'readonly');
|
||||
const store = transaction.objectStore(IMAGE_STORE_NAME);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = store.getAllKeys();
|
||||
|
||||
request.onerror = (event) => {
|
||||
log.error("Error getting all image IDs:", event.target.error);
|
||||
reject("Error getting all image IDs");
|
||||
};
|
||||
|
||||
request.onsuccess = (event) => {
|
||||
const imageIds = event.target.result;
|
||||
log.debug(`Found ${imageIds.length} image IDs in database`);
|
||||
resolve(imageIds);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function clearAllCanvasStates() {
|
||||
log.info("Clearing all canvas states...");
|
||||
const db = await openDB();
|
||||
|
||||
Reference in New Issue
Block a user