Skip to content

fix: honor the recursive parameter in list_files() - #1317

Open
yuvrajnode wants to merge 1 commit into
fishaudio:mainfrom
yuvrajnode:fix/list-files-recursive
Open

fix: honor the recursive parameter in list_files()#1317
yuvrajnode wants to merge 1 commit into
fishaudio:mainfrom
yuvrajnode:fix/list-files-recursive

Conversation

@yuvrajnode

@yuvrajnode yuvrajnode commented Aug 6, 2026

Copy link
Copy Markdown

list_files() in fish_speech/utils/file.py accepts a recursive argument and documents it as "Whether to search recursively. Defaults to False", but the implementation always called Path.rglob() — so the search was recursive no matter what the caller passed.

Impact

ReferenceLoader.list_reference_ids() calls it with recursive=False, expecting to scan only the top level of each references/<id>/ folder. Because the flag was ignored, a stray audio file in a nested subdirectory could make an otherwise-invalid reference ID appear valid.

The other two call sites (tools/vqgan/create_train_split.py, tools/vqgan/extract_vq.py) pass recursive=True, so their behavior is unchanged.

Fix

Select rglob/glob based on the flag:

globber = path.rglob if recursive else path.glob
files = [file for ext in extensions for file in globber(f"*{ext}")]

Verification

Against a demo/ tree containing top.wav and sub/nested.wav:

call before after
recursive=False top.wav, sub/nested.wav top.wav
recursive=True top.wav, sub/nested.wav top.wav, sub/nested.wav

The repo has no test suite, so I kept this to the one-line behavioral fix rather than introducing pytest as a new dependency.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

list_files() accepted a `recursive` argument and documented it as
"Whether to search recursively. Defaults to False", but the
implementation always used Path.rglob(), so the search was recursive
regardless of what the caller passed.

This affected ReferenceLoader.list_reference_ids(), which calls
list_files(ref_dir, AUDIO_EXTENSIONS, recursive=False, sort=False)
expecting to scan only the top level of each references/<id>/ folder.
A stray audio file in a nested subdirectory could make an otherwise
invalid reference ID appear valid.

Select rglob/glob based on the flag. The other two call sites pass
recursive=True, so their behavior is unchanged.
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