diff options
author | Max Kellermann <max@musicpd.org> | 2019-05-21 23:11:56 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-05-22 10:19:25 +0200 |
commit | 9a78371b5c1a38c1b8cc89e0aefd3985fdc0698a (patch) | |
tree | f8193eb37c56ba5cabcaf80c309a67803219c37f | |
parent | 3fc4da382ea8006caea005179f421813624b9fc5 (diff) |
DetachedSong: allow LoadFile(), Update() to throw
-rw-r--r-- | src/SongUpdate.cxx | 12 | ||||
-rw-r--r-- | src/song/DetachedSong.hxx | 8 | ||||
-rw-r--r-- | test/test_translate_song.cxx | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index d873c81e9..1d68698ee 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -135,10 +135,10 @@ Song::UpdateFileInArchive(ArchiveFile &archive) noexcept #endif bool -DetachedSong::LoadFile(Path path) noexcept +DetachedSong::LoadFile(Path path) { - FileInfo fi; - if (!GetFileInfo(path, fi) || !fi.IsRegular()) + const FileInfo fi(path); + if (!fi.IsRegular()) return false; TagBuilder tag_builder; @@ -151,13 +151,11 @@ DetachedSong::LoadFile(Path path) noexcept } bool -DetachedSong::Update() noexcept +DetachedSong::Update() { if (IsAbsoluteFile()) { const AllocatedPath path_fs = - AllocatedPath::FromUTF8(GetRealURI()); - if (path_fs.IsNull()) - return false; + AllocatedPath::FromUTF8Throw(GetRealURI()); return LoadFile(path_fs); } else if (IsRemote()) { diff --git a/src/song/DetachedSong.hxx b/src/song/DetachedSong.hxx index 14593d24e..07671ccf2 100644 --- a/src/song/DetachedSong.hxx +++ b/src/song/DetachedSong.hxx @@ -234,14 +234,18 @@ public: /** * Update the #tag and #mtime. * + * Throws on error. + * * @return true on success */ - bool Update() noexcept; + bool Update(); /** * Load #tag and #mtime from a local file. + * + * Throws on error. */ - bool LoadFile(Path path) noexcept; + bool LoadFile(Path path); }; #endif diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index fb6593d66..914405e2e 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -96,7 +96,7 @@ DatabaseDetachSong(gcc_unused const Database &db, } bool -DetachedSong::LoadFile(Path path) noexcept +DetachedSong::LoadFile(Path path) { if (path.ToUTF8() == uri1) { SetTag(MakeTag1a()); |