Repository navigation
Fix library scan skipping symlinked MIDI files - #39
Merged
Merged
Conversation
jdrews
marked this pull request as draft
November 12, 2026 03:18
jdrews
force-pushed
the
fix/scan-symlinked-midi
branch
from
November 12, 2026 03:20
2edc5f5 to
45a0e44
Compare
jdrews
marked this pull request as ready for review
November 12, 2026 04:18
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.
Fixes #40
Problem
Adding a library folder whose
.midfiles are symlinks (e.g. an artist-index tree linking into a flat store) yields an empty library — only folders containing regular files load.Root cause
fs:scanMidiFolder(electron/main.ts) usesreaddirSync(dir, { withFileTypes: true })and branches one.isDirectory()/e.isFile().Direntreports the entry's own type, never its target — for a symlink both arefalse, so every symlinked file fell through both branches and was silently dropped.Fix
electron/libraryScan.ts(scanMidiFolder) and resolve symlinked entries withstatSync, which follows links, to get their real typeelectron/libraryScanTest.tscovering regular files, file/dir links, broken links, dedup and a cycle — the symlink checks no-op gracefully where the OS won't permit creating themVerification
npm test: 61 files run, 0 failures;npm run typecheckcleanAof a ~100k-file artist-index tree): old logic found 0 files, new logic found 6,791 in 148 ms; the full tree scans in ~1–3 snpm run devand tested on local workstation. After starting it, all the symlinked *.mid files showed up in the library, when they didn't before this PRPlatforms
Found on Linux, but applies to Windows and macOS as well: the bug is in how Node's
Direntreports symlinks (neither file nor directory), which is consistent across all three platforms, andstatSync/realpathSyncfollow links the same way everywhere. On Windows this also covers directory junctions, which Node likewise reports as symlinks.