mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-19 00:47:01 +08:00
Handle too many files in output folder
Added a 50 png files from output folder limit. If this fails it also deletes the "DeleteAll" button to prevent deleting files that aren't on the list.
This commit is contained in:
parent
a783775268
commit
65fadd0d88
@ -148,6 +148,11 @@ class PromptServer():
|
|||||||
return web.Response(status=404)
|
return web.Response(status=404)
|
||||||
|
|
||||||
images = [f for f in os.listdir(output_dir) if f.endswith('.png')]
|
images = [f for f in os.listdir(output_dir) if f.endswith('.png')]
|
||||||
|
# Check the length of the images list
|
||||||
|
if len(images) > 50:
|
||||||
|
# If there are more than 50 images, raise an exception
|
||||||
|
return web.json_response({"error": "Too many images, load from output disabled."}, status=400)
|
||||||
|
|
||||||
return web.json_response({"images": images})
|
return web.json_response({"images": images})
|
||||||
|
|
||||||
@routes.get("/view")
|
@routes.get("/view")
|
||||||
|
|||||||
@ -153,17 +153,6 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
api.getOutput().then(data => {
|
|
||||||
try {
|
|
||||||
var images = data.filenames[0].map((filename) => {
|
|
||||||
return { filename: filename, type: 'output', subfolder: '' };
|
|
||||||
});
|
|
||||||
var output = {images: images}
|
|
||||||
var detail = {output: output}
|
|
||||||
loadImages(detail);
|
|
||||||
} catch(err){}
|
|
||||||
});
|
|
||||||
|
|
||||||
// stop resize function
|
// stop resize function
|
||||||
function stopResize() {
|
function stopResize() {
|
||||||
document.removeEventListener("mousemove", resize);
|
document.removeEventListener("mousemove", resize);
|
||||||
@ -225,7 +214,24 @@ app.registerExtension({
|
|||||||
allImages = []
|
allImages = []
|
||||||
imageList.replaceChildren(menu, resizeHandle);
|
imageList.replaceChildren(menu, resizeHandle);
|
||||||
};
|
};
|
||||||
|
api.getOutput().then(data => {
|
||||||
|
try {
|
||||||
|
if (data.message == "Success"){
|
||||||
|
var images = data.filenames[0].map((filename) => {
|
||||||
|
return { filename: filename, type: 'output', subfolder: '' };
|
||||||
|
});
|
||||||
|
var output = {images: images}
|
||||||
|
var detail = {output: output}
|
||||||
|
loadImages(detail);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deleteAllButton.setAttribute("disabled", true);
|
||||||
|
}
|
||||||
|
} catch(err){
|
||||||
|
deleteAllButton.setAttribute("disabled", true);
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
showButton.classList.add("comfy-settings-btn");
|
showButton.classList.add("comfy-settings-btn");
|
||||||
showButton.style.right = "16px";
|
showButton.style.right = "16px";
|
||||||
showButton.style.cursor = "pointer";
|
showButton.style.cursor = "pointer";
|
||||||
|
|||||||
@ -230,15 +230,21 @@ class ComfyApi extends EventTarget {
|
|||||||
* Gets the prompt execution history
|
* Gets the prompt execution history
|
||||||
* @returns Prompt history including node outputs
|
* @returns Prompt history including node outputs
|
||||||
*/
|
*/
|
||||||
async getOutput() {
|
async getOutput() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch("/output/images");
|
const res = await fetch("/output/images");
|
||||||
return { filenames: Object.values(await res.json()) };
|
if (res.status == 200){
|
||||||
} catch (error) {
|
var values = await res.json();
|
||||||
console.error(error);
|
return { filenames: Object.values(values), message: "Success" };
|
||||||
return { output: [] };
|
}
|
||||||
}
|
else {
|
||||||
}
|
return { filenames: [], message: "Failed to fetch output images" };
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return { filenames: [], message: "Failed to fetch output images" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a POST request to the API
|
* Sends a POST request to the API
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user