Skip to content

Fix file list cache invalidation on exFAT filesystems#14395

Open
Wenaka2004 wants to merge 1 commit into
Comfy-Org:masterfrom
Wenaka2004:fix/exfat-cache-invalidation
Open

Fix file list cache invalidation on exFAT filesystems#14395
Wenaka2004 wants to merge 1 commit into
Comfy-Org:masterfrom
Wenaka2004:fix/exfat-cache-invalidation

Conversation

@Wenaka2004

Copy link
Copy Markdown

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 on os.path.getmtime() to detect directory changes and invalidate its file list cache. Since mtime never changes on exFAT, the cache is never invalidated, meaning:

  • Newly added model files do not appear in node dropdowns after refreshing the page (pressing R or browser refresh)
  • Removed files continue to show up
  • The only workaround is to fully restart the ComfyUI server

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 GetVolumeInformationW API, and use directory entry count (len(os.listdir(dir))) as an additional cache invalidation signal on such filesystems.

Changes (folder_paths.py)

  1. _is_exfat(path) — New helper that detects if a path resides on an exFAT volume. Results are cached per drive letter (checked only once). Returns False on non-Windows platforms.

  2. recursive_search() — On exFAT directories, additionally records the entry count of each directory alongside its mtime.

  3. get_filename_list_() — Stores entry counts in the cache dict with a ::entry_count key suffix (to avoid key collisions with mtime values).

  4. cached_filename_list_()

    • Skips ::entry_count keys when iterating mtime entries
    • On exFAT directories, compares current os.listdir() count against the cached count — if they differ, the cache is invalidated
    • Also wraps os.path.getmtime() in a try/except for FileNotFoundError (previously unhandled)

Impact

  • NTFS / Linux / macOS: Zero behavior change — _is_exfat() returns False, no extra logic runs
  • exFAT: File list cache now correctly invalidates when files are added/removed, dropdown lists refresh properly on page reload

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.
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.

1 participant