diff options
author | Max Kellermann <max@musicpd.org> | 2020-07-06 13:36:22 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-07-06 14:13:34 +0200 |
commit | bfdf13dca365fb6ac9a5912d6a1a9efb08b2e361 (patch) | |
tree | 2f92b7a8c247b8cb70093e29d4d4d8baafa37f76 /src/SongUpdate.cxx | |
parent | daefc61aa4f603418a28994343bf21e335b2e94e (diff) |
decoder/Plugin: allow scan_{file,stream}() to throw
Bug #915 is about an I/O exception thrown where none was allowed,
leading to crash via std::terminate(). However, instead of catching
and logging the error inside the decoder plugin, it should be able to
propagate the I/O error to the MPD core, so MPD can avoid trying other
decoder plugins.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/915
Diffstat (limited to 'src/SongUpdate.cxx')
-rw-r--r-- | src/SongUpdate.cxx | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index 0743216a7..fde991bfd 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -79,17 +79,22 @@ Song::UpdateFile(Storage &storage) noexcept TagBuilder tag_builder; auto new_audio_format = AudioFormat::Undefined(); - const auto path_fs = storage.MapFS(relative_uri.c_str()); - if (path_fs.IsNull()) { - const auto absolute_uri = - storage.MapUTF8(relative_uri.c_str()); - if (!tag_stream_scan(absolute_uri.c_str(), tag_builder, - &new_audio_format)) - return false; - } else { - if (!ScanFileTagsWithGeneric(path_fs, tag_builder, + try { + const auto path_fs = storage.MapFS(relative_uri.c_str()); + if (path_fs.IsNull()) { + const auto absolute_uri = + storage.MapUTF8(relative_uri.c_str()); + if (!tag_stream_scan(absolute_uri.c_str(), tag_builder, &new_audio_format)) - return false; + return false; + } else { + if (!ScanFileTagsWithGeneric(path_fs, tag_builder, + &new_audio_format)) + return false; + } + } catch (...) { + // TODO: log or propagate I/O errors? + return false; } mtime = info.mtime; @@ -153,8 +158,14 @@ DetachedSong::LoadFile(Path path) noexcept return false; TagBuilder tag_builder; - if (!ScanFileTagsWithGeneric(path, tag_builder)) + + try { + if (!ScanFileTagsWithGeneric(path, tag_builder)) + return false; + } catch (...) { + // TODO: log or propagate I/O errors? return false; + } mtime = fi.GetModificationTime(); tag_builder.Commit(tag); @@ -173,8 +184,14 @@ DetachedSong::Update() noexcept return LoadFile(path_fs); } else if (IsRemote()) { TagBuilder tag_builder; - if (!tag_stream_scan(uri.c_str(), tag_builder)) + + try { + if (!tag_stream_scan(uri.c_str(), tag_builder)) + return false; + } catch (...) { + // TODO: log or propagate I/O errors? return false; + } mtime = std::chrono::system_clock::time_point::min(); tag_builder.Commit(tag); |