rust-mpd icon indicating copy to clipboard operation
rust-mpd copied to clipboard

Adding non-existing song to queue hangs

Open naglis opened this issue 2 years ago • 0 comments

Using latest commit from main branch with following test:

#[test]
#[should_panic(expected = "Failed to access")]
fn add_non_existing_song_returns_error() {
    let mut mpd = connect();
    let _song_id = mpd.push(Song { file: "file:///hopefully/non/existing/song.mp3".to_string(), ..Default::default() }).unwrap();
}

results in the MPD connection hanging until MPD closes the client connection due to inactivity and the returned error is Parse(BadPair).

IIUC this is caused by the read_pair() implementation introduced in 8642c7254690b418a451f228a348de6adc4bcfb3. It parses the error ACK [52@0] {addid} Failed to access /hopefully/non/existing/song.mp3: No such file or directory returned by MPD as the song ID value and then read_field hangs when waiting for expect_ok(), since there is no OK line in case of an error.

naglis avatar Oct 11 '23 20:10 naglis