Commit 9a78371b authored by Max Kellermann's avatar Max Kellermann

DetachedSong: allow LoadFile(), Update() to throw

parent 3fc4da38
...@@ -135,10 +135,10 @@ Song::UpdateFileInArchive(ArchiveFile &archive) noexcept ...@@ -135,10 +135,10 @@ Song::UpdateFileInArchive(ArchiveFile &archive) noexcept
#endif #endif
bool bool
DetachedSong::LoadFile(Path path) noexcept DetachedSong::LoadFile(Path path)
{ {
FileInfo fi; const FileInfo fi(path);
if (!GetFileInfo(path, fi) || !fi.IsRegular()) if (!fi.IsRegular())
return false; return false;
TagBuilder tag_builder; TagBuilder tag_builder;
...@@ -151,13 +151,11 @@ DetachedSong::LoadFile(Path path) noexcept ...@@ -151,13 +151,11 @@ DetachedSong::LoadFile(Path path) noexcept
} }
bool bool
DetachedSong::Update() noexcept DetachedSong::Update()
{ {
if (IsAbsoluteFile()) { if (IsAbsoluteFile()) {
const AllocatedPath path_fs = const AllocatedPath path_fs =
AllocatedPath::FromUTF8(GetRealURI()); AllocatedPath::FromUTF8Throw(GetRealURI());
if (path_fs.IsNull())
return false;
return LoadFile(path_fs); return LoadFile(path_fs);
} else if (IsRemote()) { } else if (IsRemote()) {
......
...@@ -234,14 +234,18 @@ public: ...@@ -234,14 +234,18 @@ public:
/** /**
* Update the #tag and #mtime. * Update the #tag and #mtime.
* *
* Throws on error.
*
* @return true on success * @return true on success
*/ */
bool Update() noexcept; bool Update();
/** /**
* Load #tag and #mtime from a local file. * Load #tag and #mtime from a local file.
*
* Throws on error.
*/ */
bool LoadFile(Path path) noexcept; bool LoadFile(Path path);
}; };
#endif #endif
...@@ -96,7 +96,7 @@ DatabaseDetachSong(gcc_unused const Database &db, ...@@ -96,7 +96,7 @@ DatabaseDetachSong(gcc_unused const Database &db,
} }
bool bool
DetachedSong::LoadFile(Path path) noexcept DetachedSong::LoadFile(Path path)
{ {
if (path.ToUTF8() == uri1) { if (path.ToUTF8() == uri1) {
SetTag(MakeTag1a()); SetTag(MakeTag1a());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment