Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date based folder sorting as default when saving images #6785

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

silveroxides
Copy link
Contributor

This is to mitigate issues with Windows explorer not being able to handle large amounts of files in a folder.
Without this, on a top end NVMe SSD and 2000 images in output folder, sorting by date can take up to a minute each time output folder is opened.
This can be prevented by automatically sorting images in subdirectories based on date as then it is unlikely that a single folder will accumulate an excessive amount of images.

@catboxanon
Copy link
Contributor

Other relevant PR: #6387

@silveroxides
Copy link
Contributor Author

silveroxides commented Feb 12, 2025

Other relevant PR: #6387

Trying to process your response there. Are you saying that these changes are not processed by the backend?
Cause I tested the code and it does create a new folder with the current date in the ouput directory.
I see no issue in this. It is not the Frontend that saves the image to ouput directory in the save image node and that the syntax is being parsed on frontend with the function formatDate makes sense.

Is there any other use case where this change would conflict? I can't really see how there would be.
If the issue is that date formatting is not supported on backend, then I guess I could whip together a regular expression function for that.

The main issue my PR is aiming at solving is how the current way output is handled with images will, given enough generations, cause that folder to be rendered unusable for Windows OS user due to it trying to handle too many file properties at once.

Testing of this issue was done on a system running 2TB PCIe v4 NVME m.2 SSD with the following specs
Sequential read/write – 7,300/7,000MB/s
Random 4K read/write – up to 1,000,000/1,000,000 IOPS

After folder accumulated 4000 images, it took over 2 minutes for it to sort images by date.

@catboxanon
Copy link
Contributor

Are you saying that these changes are not processed by the backend?

Correct. If you uncheck this, the special date formatting will be ignored.

image

@silveroxides
Copy link
Contributor Author

Correct. If you uncheck this, the special date formatting will be ignored.

Well this is simply ridiculous though.
Do we have any telemetry on how many users have this one turned off? Is there any reason for users to actually turn it off?
I can't see any reason why this extensions slim to no possibility of user turning it off while at the same time not know what it does and as such most likely would understand to set their own default.
I feel like any argument regarding this is completely irrelevant for actual use.
It would have been another thing if it broke something or had high likelihood of breaking.

@catboxanon
Copy link
Contributor

catboxanon commented Feb 14, 2025

The problem I see is that if a workflow is exported for API use, which means no frontend is in use, the API won't honor that syntax. This is speaking from my own experience as well -- I originally had thought that syntax was handled in the backend, so I was really confused why this was "broken" until I learned it's a frontend only feature.

If we modify the node default, in my view that would lead many to believe the behavior of this node would be consistent regardless if they use a frontend that supports it or not, or no frontend at all.

@silveroxides
Copy link
Contributor Author

silveroxides commented Feb 14, 2025

@catboxanon Have you tested this pull request and confirmed that this is the case with the API?
I have never used the API myself so I would appreciate if you could test and confirm what you say is true.
EDIT
Realized I could just turn off the frontend extension to test, so no need.

@silveroxides
Copy link
Contributor Author

@catboxanon My latest commit to this PR should handle cases where the is no Frontend present such as API.

@without-ordinary
Copy link

A workable alternative (for me) would be an option to set the default save string to a custom value.

silveroxides and others added 8 commits February 19, 2025 10:37
I overhauled save_image_path to handle more exceptions, handle exceptions correctly, properly handle cases where "Comfy.SaveImageExtraOutput" is disabled or API use cases where there is no frontend to parse frontend syntax for date formatting, This will handle all variations of user date format input that is used on either web frontend format("%date:yyyy-MM-dd-hh-mm-ss%") or if they choose to use backend format("%year%-%month%-%day%-%hour%-%minute%-%second%") directly.
Remove trailing whitespaces.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants