SongLoader: move code to LoadFromDatabase()
Avoids the recursion in LoadFile().
This commit is contained in:
parent
bea5973e0c
commit
1a5b66b78d
@ -41,6 +41,21 @@ SongLoader::SongLoader(const Client &_client)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DetachedSong *
|
||||||
|
SongLoader::LoadFromDatabase(const char *uri, Error &error) const
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_DATABASE
|
||||||
|
if (db != nullptr)
|
||||||
|
return DatabaseDetachSong(*db, *storage, uri, error);
|
||||||
|
#else
|
||||||
|
(void)uri;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
|
||||||
|
"No database");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
DetachedSong *
|
DetachedSong *
|
||||||
SongLoader::LoadFile(const char *path_utf8, Error &error) const
|
SongLoader::LoadFile(const char *path_utf8, Error &error) const
|
||||||
{
|
{
|
||||||
@ -50,7 +65,7 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const
|
|||||||
if (suffix != nullptr)
|
if (suffix != nullptr)
|
||||||
/* this path was relative to the music
|
/* this path was relative to the music
|
||||||
directory - obtain it from the database */
|
directory - obtain it from the database */
|
||||||
return LoadSong(suffix, error);
|
return LoadFromDatabase(suffix, error);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -99,14 +114,6 @@ SongLoader::LoadSong(const char *uri_utf8, Error &error) const
|
|||||||
} else {
|
} else {
|
||||||
/* URI relative to the music directory */
|
/* URI relative to the music directory */
|
||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
return LoadFromDatabase(uri_utf8, error);
|
||||||
if (db != nullptr)
|
|
||||||
return DatabaseDetachSong(*db, *storage,
|
|
||||||
uri_utf8, error);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
|
|
||||||
"No database");
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,9 @@ public:
|
|||||||
DetachedSong *LoadSong(const char *uri_utf8, Error &error) const;
|
DetachedSong *LoadSong(const char *uri_utf8, Error &error) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
gcc_nonnull_all
|
||||||
|
DetachedSong *LoadFromDatabase(const char *uri, Error &error) const;
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
DetachedSong *LoadFile(const char *path_utf8, Error &error) const;
|
DetachedSong *LoadFile(const char *path_utf8, Error &error) const;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user