Fix file list cache invalidation on exFAT filesystems#14395
Open
Wenaka2004 wants to merge 1 commit into
Open
Conversation
On exFAT volumes, directory mtime does not update when files are added or removed, causing ComfyUI's mtime-based cache invalidation in folder_paths to never detect changes. This means newly added model files do not appear in node dropdowns until the server is restarted. Fix: detect exFAT volumes via Win32 API and use directory entry count as an additional cache invalidation signal on such filesystems. NTFS and other platforms are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On exFAT volumes (common on external/large drives on Windows), directory modification time (
mtime) does not update when files are added or removed. This is a known exFAT filesystem limitation.ComfyUI's
cached_filename_list_()relies entirely onos.path.getmtime()to detect directory changes and invalidate its file list cache. Since mtime never changes on exFAT, the cache is never invalidated, meaning:Users on NTFS (the default Windows filesystem) are unaffected because NTFS correctly updates directory mtime on file changes.
Fix
Detect exFAT volumes at runtime via the Win32
GetVolumeInformationWAPI, and use directory entry count (len(os.listdir(dir))) as an additional cache invalidation signal on such filesystems.Changes (
folder_paths.py)_is_exfat(path)— New helper that detects if a path resides on an exFAT volume. Results are cached per drive letter (checked only once). ReturnsFalseon non-Windows platforms.recursive_search()— On exFAT directories, additionally records the entry count of each directory alongside its mtime.get_filename_list_()— Stores entry counts in the cache dict with a::entry_countkey suffix (to avoid key collisions with mtime values).cached_filename_list_()—::entry_countkeys when iterating mtime entriesos.listdir()count against the cached count — if they differ, the cache is invalidatedos.path.getmtime()in a try/except forFileNotFoundError(previously unhandled)Impact
_is_exfat()returnsFalse, no extra logic runs