fix get-song returning "no data" instead of loading the song

This commit is contained in:
Mark 2024-03-28 18:55:20 +01:00
parent b70d922fad
commit 8b8f13f98a
2 changed files with 3 additions and 5 deletions

View File

@ -112,7 +112,7 @@ impl Song {
None
}
}
/// Gets the cached data, if available.
/// Gets or loads the cached data.
/// If a thread is running to load the data, it *is* awaited.
/// This function will block until the data is loaded.
/// If it still returns none, some error must have occured.

View File

@ -122,10 +122,8 @@ pub fn handle_one_connection_as_get(
.next()
.and_then(|id| id.parse().ok())
.and_then(|id| {
db.lock()
.unwrap()
.get_song(&id)
.and_then(|song| song.cached_data())
let db = db.lock().unwrap();
db.get_song(&id).and_then(|song| song.cached_data_now(&db))
})
{
writeln!(connection.get_mut(), "len: {}", bytes.len())?;