Merge pull request 'When no media-specific top level directories exist, assume everything is music' (#119) from jqln/no-media-types into main

Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/119
custom
ailurux 4 months ago
commit b3e1e88ba2
  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> {
// TODO(jacqueline): This probably needs to be async? When we have runtime
// configurable indexes, they will need to come from somewhere.
return {
kAllTracks, kAllAlbums, kAlbumsByArtist, kTracksByGenre, kPodcasts, kAudiobooks
};
return {kAllTracks, kAllAlbums, kAlbumsByArtist,
kTracksByGenre, kPodcasts, kAudiobooks};
}
Database::UpdateTracker::UpdateTracker()
@ -568,6 +567,23 @@ auto Database::calculateMediaType(TrackTags& tags, std::string_view path)
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;
}

Loading…
Cancel
Save