db/upnp: simplify GetSong()
This commit is contained in:
parent
7471f65d95
commit
dc5ef9ad01
|
@ -219,9 +219,12 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const
|
|||
const LightSong *
|
||||
UpnpDatabase::GetSong(const char *uri, Error &error) const
|
||||
{
|
||||
UpnpSong *song = nullptr;
|
||||
auto vpath = stringToTokens(uri, "/", true);
|
||||
if (vpath.size() >= 2) {
|
||||
if (vpath.size() < 2) {
|
||||
error.Format(db_domain, DB_NOT_FOUND, "No such song: %s", uri);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ContentDirectoryService server;
|
||||
if (!m_superdir->getServer(vpath[0].c_str(), server, error))
|
||||
return nullptr;
|
||||
|
@ -238,12 +241,7 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
song = new UpnpSong(std::move(dirent), uri);
|
||||
}
|
||||
if (song == nullptr)
|
||||
error.Format(db_domain, DB_NOT_FOUND, "No such song: %s", uri);
|
||||
|
||||
return song;
|
||||
return new UpnpSong(std::move(dirent), uri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue