mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
Enhanced the canvas save mechanism to ensure unique file names per node, prevent concurrent saves and executions, and handle missing files more robustly. Switched all logger levels to DEBUG for detailed tracing. Added fallback logic for file naming, improved error handling, and ensured that empty canvases are not saved. These changes improve reliability and traceability of canvas operations, especially in multi-node scenarios.
38 lines
965 B
JavaScript
38 lines
965 B
JavaScript
import {logger, LogLevel} from "./logger.js";
|
|
|
|
// Inicjalizacja loggera dla modułu ImageCache
|
|
const log = {
|
|
debug: (...args) => logger.debug('ImageCache', ...args),
|
|
info: (...args) => logger.info('ImageCache', ...args),
|
|
warn: (...args) => logger.warn('ImageCache', ...args),
|
|
error: (...args) => logger.error('ImageCache', ...args)
|
|
};
|
|
|
|
// Konfiguracja loggera dla modułu ImageCache
|
|
logger.setModuleLevel('ImageCache', LogLevel.DEBUG);
|
|
|
|
export class ImageCache {
|
|
constructor() {
|
|
this.cache = new Map();
|
|
}
|
|
|
|
set(key, imageData) {
|
|
log.info("Caching image data for key:", key);
|
|
this.cache.set(key, imageData);
|
|
}
|
|
|
|
get(key) {
|
|
const data = this.cache.get(key);
|
|
log.debug("Retrieved cached data for key:", key, !!data);
|
|
return data;
|
|
}
|
|
|
|
has(key) {
|
|
return this.cache.has(key);
|
|
}
|
|
|
|
clear() {
|
|
log.info("Clearing image cache");
|
|
this.cache.clear();
|
|
}
|
|
} |