Refactor "no-password-fix"

Refactors the fix for the use case of when MPD requires no password.
This commit is contained in:
Stephen Seo 2023-02-04 21:32:09 +09:00
parent a1706913e6
commit aa6fb750e7

View file

@ -250,6 +250,8 @@ impl MPDHandler {
) )
.map_err(|_| String::from("Failed to get TCP connection (is MPD running?)"))?; .map_err(|_| String::from("Failed to get TCP connection (is MPD running?)"))?;
let password_is_empty = password.is_empty();
let s = MPDHandler { let s = MPDHandler {
state: Arc::new(RwLock::new(MPDHandlerState { state: Arc::new(RwLock::new(MPDHandlerState {
art_data: Vec::new(), art_data: Vec::new(),
@ -263,10 +265,10 @@ impl MPDHandler {
current_binary_size: 0, current_binary_size: 0,
poll_state: PollState::None, poll_state: PollState::None,
stream, stream,
password: password.clone(), password,
error_text: String::new(), error_text: String::new(),
can_authenticate: true, can_authenticate: true,
is_authenticated: password.is_empty(), is_authenticated: password_is_empty,
can_get_album_art: true, can_get_album_art: true,
can_get_album_art_in_dir: true, can_get_album_art_in_dir: true,
can_get_status: true, can_get_status: true,