This commit is contained in:
Max Kellermann 2022-12-29 08:37:25 +01:00
commit d7de8b1453

View File

@ -28,6 +28,7 @@
#include "song/DetachedSong.hxx" #include "song/DetachedSong.hxx"
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "fs/Traits.hxx" #include "fs/Traits.hxx"
#include "Log.hxx"
#ifdef ENABLE_DATABASE #ifdef ENABLE_DATABASE
#include "SongLoader.hxx" #include "SongLoader.hxx"
@ -41,12 +42,14 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
playlist &dest, PlayerControl &pc, playlist &dest, PlayerControl &pc,
const SongLoader &loader) const SongLoader &loader)
{ {
const unsigned max_log_msgs = 8;
const auto base_uri = uri != nullptr const auto base_uri = uri != nullptr
? PathTraitsUTF8::GetParent(uri) ? PathTraitsUTF8::GetParent(uri)
: "."; : ".";
std::unique_ptr<DetachedSong> song; std::unique_ptr<DetachedSong> song;
for (unsigned i = 0; for (unsigned i = 0, failures = 0;
i < end_index && (song = e.NextSong()) != nullptr; i < end_index && (song = e.NextSong()) != nullptr;
++i) { ++i) {
if (i < start_index) { if (i < start_index) {
@ -56,6 +59,12 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
if (!playlist_check_translate_song(*song, base_uri, if (!playlist_check_translate_song(*song, base_uri,
loader)) { loader)) {
failures += 1;
if (failures < max_log_msgs) {
FmtError(playlist_domain, "Failed to load \"{}\".", song->GetURI());
} else if (failures == max_log_msgs) {
LogError(playlist_domain, "Further errors for this playlist will not be logged.");
}
continue; continue;
} }