More robust handling of authentication failure

Bump version to 0.2.15
This commit is contained in:
Stephen Seo 2022-01-13 11:17:32 +09:00
parent a48f801a02
commit e12104aa20
4 changed files with 12 additions and 6 deletions

2
Cargo.lock generated
View file

@ -1427,7 +1427,7 @@ dependencies = [
[[package]]
name = "mpd_info_screen"
version = "0.2.14"
version = "0.2.15"
dependencies = [
"ggez",
"image",

View file

@ -1,6 +1,6 @@
[package]
name = "mpd_info_screen"
version = "0.2.14"
version = "0.2.15"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -9,7 +9,7 @@ counter, and the filename currently being played
# Usage
mpd_info_screen 0.2.14
mpd_info_screen 0.2.15
USAGE:
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]

View file

@ -385,7 +385,10 @@ impl MPDHandler {
}
'main: loop {
if !self.is_reading_picture() {
if !self.is_reading_picture()
|| (!self.is_authenticated().ok().unwrap_or(false)
&& !self.failed_to_authenticate().ok().unwrap_or(false))
{
thread::sleep(SLEEP_DURATION);
if let Ok(write_handle) = self.state.try_write() {
if write_handle.self_thread.is_none() {
@ -415,7 +418,7 @@ impl MPDHandler {
}
if let Ok(read_handle) = self.state.try_read() {
if read_handle.stop_flag.load(Ordering::Relaxed) {
if read_handle.stop_flag.load(Ordering::Relaxed) || !read_handle.can_authenticate {
break 'main;
}
}
@ -557,7 +560,7 @@ impl MPDHandler {
write_handle.poll_state = PollState::None;
break 'handle_buf;
} else if line.starts_with("ACK") {
log(line, LogState::Warning, write_handle.log_level);
log(&line, LogState::Warning, write_handle.log_level);
match write_handle.poll_state {
PollState::Password => {
write_handle.can_authenticate = false;
@ -569,6 +572,9 @@ impl MPDHandler {
write_handle.can_get_status = false;
write_handle.dirty_flag.store(true, Ordering::Relaxed);
write_handle.error_text = "Failed to get MPD status".into();
if line.contains("don't have permission") {
write_handle.can_authenticate = false;
}
}
PollState::ReadPicture => {
write_handle.can_get_album_art = false;