]> git.seodisparate.com - mpd_info_screen/commitdiff
Refactor "no-password-fix"
authorStephen Seo <seo.disparate@gmail.com>
Sat, 4 Feb 2023 12:32:09 +0000 (21:32 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 4 Feb 2023 12:32:31 +0000 (21:32 +0900)
Refactors the fix for the use case of when MPD requires no password.

src/mpd_handler.rs

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