More robust handling of authentication failure
Bump version to 0.2.15
This commit is contained in:
parent
a48f801a02
commit
e12104aa20
4 changed files with 12 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1427,7 +1427,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mpd_info_screen"
|
name = "mpd_info_screen"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ggez",
|
"ggez",
|
||||||
"image",
|
"image",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "mpd_info_screen"
|
name = "mpd_info_screen"
|
||||||
version = "0.2.14"
|
version = "0.2.15"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
|
@ -9,7 +9,7 @@ counter, and the filename currently being played
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
mpd_info_screen 0.2.14
|
mpd_info_screen 0.2.15
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]
|
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]
|
||||||
|
|
|
@ -385,7 +385,10 @@ impl MPDHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
'main: loop {
|
'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);
|
thread::sleep(SLEEP_DURATION);
|
||||||
if let Ok(write_handle) = self.state.try_write() {
|
if let Ok(write_handle) = self.state.try_write() {
|
||||||
if write_handle.self_thread.is_none() {
|
if write_handle.self_thread.is_none() {
|
||||||
|
@ -415,7 +418,7 @@ impl MPDHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(read_handle) = self.state.try_read() {
|
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;
|
break 'main;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,7 +560,7 @@ impl MPDHandler {
|
||||||
write_handle.poll_state = PollState::None;
|
write_handle.poll_state = PollState::None;
|
||||||
break 'handle_buf;
|
break 'handle_buf;
|
||||||
} else if line.starts_with("ACK") {
|
} 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 {
|
match write_handle.poll_state {
|
||||||
PollState::Password => {
|
PollState::Password => {
|
||||||
write_handle.can_authenticate = false;
|
write_handle.can_authenticate = false;
|
||||||
|
@ -569,6 +572,9 @@ impl MPDHandler {
|
||||||
write_handle.can_get_status = false;
|
write_handle.can_get_status = false;
|
||||||
write_handle.dirty_flag.store(true, Ordering::Relaxed);
|
write_handle.dirty_flag.store(true, Ordering::Relaxed);
|
||||||
write_handle.error_text = "Failed to get MPD status".into();
|
write_handle.error_text = "Failed to get MPD status".into();
|
||||||
|
if line.contains("don't have permission") {
|
||||||
|
write_handle.can_authenticate = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PollState::ReadPicture => {
|
PollState::ReadPicture => {
|
||||||
write_handle.can_get_album_art = false;
|
write_handle.can_get_album_art = false;
|
||||||
|
|
Loading…
Reference in a new issue