1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 10:41:03 +02:00

fix(mpd): incorrectly checking for unix sockets

This commit is contained in:
Jake Stanger 2022-10-15 00:17:40 +01:00
parent 006c242f49
commit 8536ad719a
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -6,6 +6,7 @@ use mpd_client::responses::Status;
use mpd_client::Client; use mpd_client::Client;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::os::unix::fs::FileTypeExt;
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
@ -137,7 +138,12 @@ async fn try_get_mpd_conn(host: &str) -> Result<Connection, MpdProtocolError> {
} }
fn is_unix_socket(host: &str) -> bool { fn is_unix_socket(host: &str) -> bool {
PathBuf::from(host).is_file() let path = PathBuf::from(host);
path.exists()
&& match path.metadata() {
Ok(metadata) => metadata.file_type().is_socket(),
Err(_) => false,
}
} }
async fn connect_unix(host: &str) -> Result<Connection, MpdProtocolError> { async fn connect_unix(host: &str) -> Result<Connection, MpdProtocolError> {