Fix allowed directory handling and add smart view#490
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| val allowedDirs = userPreferencesRepository.allowedDirectoriesFlow.first() | ||
| if (allowedDirs.isEmpty()) { | ||
| val allAudioDirs = musicRepository.getAllUniqueAudioDirectories().toSet() | ||
| userPreferencesRepository.updateAllowedDirectories(allAudioDirs) | ||
| val musicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) | ||
| val defaultAllowed = if (musicDir.exists()) { | ||
| runCatching { musicDir.canonicalPath }.getOrDefault(musicDir.absolutePath) | ||
| } else null | ||
| userPreferencesRepository.updateAllowedDirectories(defaultAllowed?.let { setOf(it) } ?: emptySet()) |
There was a problem hiding this comment.
Defaulting to empty allowed dirs bricks library when Music folder absent
If the device doesn’t have a DIRECTORY_MUSIC folder (common when music lives on SD cards or custom storage), loadMusicDirectories sets the allowed directory set to emptySet() (lines 101‑107). Because MusicRepositoryImpl.filterAllowed now always drops all songs whenever the allowed set is empty (lines 107‑115 in that file), completing setup after skipping folder selection leaves the library permanently empty even though audio files exist elsewhere. There’s no fallback to the previously detected audio folders (the old auto-populate was removed), so users without a Music folder must manually dig into settings to add directories or the app shows no content.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task