db/simple/Song: allow LoadFile(), UpdateFile() to throw

Preparing to move logger calls out of lower-level libaries, and
propagating error details to the caller instead.
This commit is contained in:
Max Kellermann
2019-05-21 22:56:08 +02:00
parent 6ee7d88af0
commit 3fc4da382e
3 changed files with 21 additions and 13 deletions

View File

@@ -42,8 +42,7 @@
#ifdef ENABLE_DATABASE
SongPtr
Song::LoadFile(Storage &storage, const char *path_utf8,
Directory &parent) noexcept
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
{
assert(!uri_has_scheme(path_utf8));
assert(strchr(path_utf8, '\n') == nullptr);
@@ -60,17 +59,11 @@ Song::LoadFile(Storage &storage, const char *path_utf8,
#ifdef ENABLE_DATABASE
bool
Song::UpdateFile(Storage &storage) noexcept
Song::UpdateFile(Storage &storage)
{
const auto &relative_uri = GetURI();
StorageFileInfo info;
try {
info = storage.GetInfo(relative_uri.c_str(), true);
} catch (...) {
return false;
}
const auto info = storage.GetInfo(relative_uri.c_str(), true);
if (!info.IsRegular())
return false;