When no media-specific top level directories exist, assume everything is music

custom
jacqueline 4 months ago
parent 287c4bfb26
commit 96e2fdd4e2
  1. 22
      src/tangara/database/database.cpp

@ -292,9 +292,8 @@ auto Database::setTrackData(TrackId id, const TrackData& data) -> void {
auto Database::getIndexes() -> std::vector<IndexInfo> { auto Database::getIndexes() -> std::vector<IndexInfo> {
// TODO(jacqueline): This probably needs to be async? When we have runtime // TODO(jacqueline): This probably needs to be async? When we have runtime
// configurable indexes, they will need to come from somewhere. // configurable indexes, they will need to come from somewhere.
return { return {kAllTracks, kAllAlbums, kAlbumsByArtist,
kAllTracks, kAllAlbums, kAlbumsByArtist, kTracksByGenre, kPodcasts, kAudiobooks kTracksByGenre, kPodcasts, kAudiobooks};
};
} }
Database::UpdateTracker::UpdateTracker() Database::UpdateTracker::UpdateTracker()
@ -568,6 +567,23 @@ auto Database::calculateMediaType(TrackTags& tags, std::string_view path)
return MediaType::kMusic; return MediaType::kMusic;
} }
auto dir_exists = [&](auto path) {
FF_DIR dir;
bool res = f_opendir(&dir, path);
if (res == FR_OK) {
f_closedir(&dir);
}
return res == FR_OK;
};
// As a special case, if no media-specific paths exist at all, then assume
// the user doesn't really care about alternate media types and just wants to
// use the device for music.
if (!dir_exists(kMusicMediaPath) && !dir_exists(kPodcastMediaPath) &&
!dir_exists(kAudiobookMediaPath)) {
return MediaType::kMusic;
}
return MediaType::kUnknown; return MediaType::kUnknown;
} }

Loading…
Cancel
Save