diff --git a/musicdb-lib/src/data/song.rs b/musicdb-lib/src/data/song.rs index 9e73fe3..823f6fd 100755 --- a/musicdb-lib/src/data/song.rs +++ b/musicdb-lib/src/data/song.rs @@ -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. diff --git a/musicdb-lib/src/server/get.rs b/musicdb-lib/src/server/get.rs index 9cd9aa2..d901d48 100755 --- a/musicdb-lib/src/server/get.rs +++ b/musicdb-lib/src/server/get.rs @@ -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())?;