extract ~/-expanding expandHome to fileUtils + add HF download --local-dir / --ignore flags#526
Merged
Merged
Conversation
…-local-dir` / `--ignore` flags
`expandHome` was duplicated inline in `server/lib/mediaModels.js` and
`server/services/referenceRepos.js`. Moved to `server/lib/fileUtils.js`
and added a `typeof p !== 'string'` guard so a non-string input falls
through instead of throwing on `.startsWith` (the old mediaModels copy
would have thrown). Updated the lib README and barrel-tracked exports.
`scripts/hf_download_repo.py` gains two flags needed by the upcoming
HiDream-O1 BYOV installer:
--local-dir materialize the repo as a flat copy at a given path
instead of relying on the standard HF cache symlinks
(HiDream-O1's installer needs a real on-disk repo)
--ignore PAT fnmatch glob skip filter, repeatable — lets the caller
drop non-weight subdirs (scripts/, docs/) on download
Also backfills `RUNNER_FAMILIES.HIDREAM` / `QWEN` cases in
`server/lib/runners.test.js` (the runtime module already exports them
and the client mirror already carries them — the test was stale).
…ect unit tests - voice/config.js `expandPath` is now a re-export of the shared `expandHome` (5 caller sites under server/services/voice/ keep working via the alias). - routes/scaffold.js now routes its `~` / `~/` / `~\` handling through `expandHome` instead of its own inline branch — required extending `expandHome` to also accept `~\` (Windows). Embedded `~` chars (e.g. `iCloud~md~obsidian`) still pass through unchanged. - lib/fileUtils.test.js gets a direct describe block for `expandHome` covering bare `~`, `~/foo`, `~\foo`, absolute / relative / empty passthrough, non-string passthrough, and the embedded-tilde case. - runners.test.js now exercises `isQwen` alongside `isHiDream` so the predicate pair stays in sync if either is renamed/dropped.
Gemini's /do:review pass against PR #526 surfaced a real-looking latent bug in `server/services/videoGen/local.js:571` — the `lastImageWillBeUsed` gate skips the ltx2 FFLF case where both start AND end frames are provided, leaving the end frame unresized. Out-of-scope from PR #526 (which only touches `expandHome` consolidation + HF download flags), so filed as a PLAN follow-up for verification + triage instead of applying.
Contributor
There was a problem hiding this comment.
Pull request overview
Consolidates ~ / ~/... home-directory expansion into a shared server/lib/fileUtils.js#expandHome, updates server callsites to use it, and extends the HuggingFace prefetch script to support BYOV-style downloads via --local-dir plus selective skipping via --ignore.
Changes:
- Extract
expandHomeintoserver/lib/fileUtils.jsand update callsites (voice config path expansion, reference repos, scaffold directory browsing, media models). - Add
--local-dirand repeatable--ignoreglob patterns toscripts/hf_download_repo.py. - Refresh runner-family tests to include HIDREAM/QWEN and document
expandHomein the lib README.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/services/voice/config.js | Replaces local expandPath implementation with expandHome alias for shared behavior. |
| server/services/referenceRepos.test.js | Updates fileUtils mock to include expandHome. |
| server/services/referenceRepos.js | Uses shared expandHome from fileUtils instead of inline helper. |
| server/routes/scaffold.js | Uses shared expandHome for ~ path handling in directory browser route. |
| server/lib/runners.test.js | Extends runner-family assertions and predicate tests to HIDREAM/QWEN. |
| server/lib/README.md | Documents expandHome as a fileUtils.js export. |
| server/lib/mediaModels.js | Uses shared expandHome for localPath expansion. |
| server/lib/fileUtils.test.js | Adds unit tests covering expandHome behavior and edge cases. |
| server/lib/fileUtils.js | Introduces expandHome(p) utility. |
| scripts/hf_download_repo.py | Adds --local-dir + --ignore and wires them into download flow. |
| PLAN.md | Adds a planning note about a potential ltx2 FFLF resize issue (out of scope of the code changes). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ymlinks) `hf_hub_download(..., local_dir=...)` defaulted to symlinking into the HF cache on huggingface_hub < 0.23 — which defeats the whole point of `--local-dir` for BYOV installers like HiDream-O1 that need real files to walk a flat on-disk repo. Pass `local_dir_use_symlinks=False` whenever `--local-dir` is set, but gate it on a one-time `inspect.signature` probe: newer huggingface_hub deprecated the kwarg (always copies) and eventually removed it, so the probe keeps us forward-compatible as the FLUX.2 venv rolls upstream.
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.
Summary
expandHomeextracted toserver/lib/fileUtils.js. The same~/foo→ absolute helper was inlined inserver/lib/mediaModels.jsandserver/services/referenceRepos.js. Consolidated into one shared export and added atypeof p !== 'string'guard so non-string input falls through instead of throwing on.startsWith(the oldmediaModelscopy would have thrown). Re-exported via theserver/lib/index.jsbarrel and documented in the lib README.scripts/hf_download_repo.pygains--local-dirand--ignoreflags. Both are needed by the upcoming HiDream-O1 BYOV installer:--local-dirmaterializes the repo as a flat copy (HiDream-O1's installer needs a real on-disk repo, not the standard HF cache symlinks);--ignoreis a repeatable fnmatch skip pattern so the caller can drop non-weight subdirs (scripts/,docs/) on download.server/lib/runners.test.jsbackfilled for HIDREAM/QWEN. The runtime module already exports both runner-family ids and the client mirror already carries them — the test was stale and only checked the original four (mflux,flux2,z-image,ernie).Test plan
npm test -- --run lib/runners.test.js services/referenceRepos.test.js lib/mediaModels.test.js lib/index.test.js— 38 passed, 0 failed--local-dir+--ignore(deferred to the installer PR that exercises these flags)