Compare commits

...

2 commits

Author SHA1 Message Date
26a3381a25
Remove dbg! calls in mpd.rs
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-14 15:52:43 +02:00
138446e040
Format and apply Clippy suggestions 2023-05-14 15:46:43 +02:00
2 changed files with 9 additions and 11 deletions

View file

@ -1,4 +1,4 @@
use std::{path::Path, collections::HashMap};
use std::{collections::HashMap, path::Path};
use askama::Template;
use percent_encoding::percent_decode_str;
@ -176,7 +176,8 @@ struct UpdateQueueBody {
async fn post_queue_move(mut req: tide::Request<()>) -> tide::Result {
let body: UpdateQueueBody = req.body_json().await?;
let mut mpd = mpd::Mpd::connect().await?;
mpd.command(&format!("move {} {}", body.from, body.to)).await?;
mpd.command(&format!("move {} {}", body.from, body.to))
.await?;
Ok("".into())
}

View file

@ -104,7 +104,6 @@ impl Mpd {
stream.write_all(b"binarylimit 1048576\n").await?;
buffer.clear();
reader.read_line(&mut buffer).await?;
dbg!(&buffer);
Ok(Self { stream, reader })
}
@ -126,7 +125,6 @@ impl Mpd {
}
pub async fn command(&mut self, command: &str) -> anyhow::Result<CommandResult> {
dbg!(command);
let mut properties = Vec::new();
self.stream
@ -151,7 +149,6 @@ impl Mpd {
});
}
} else if buffer.starts_with("OK") {
dbg!(&properties);
break Ok(CommandResult {
properties,
binary: None,
@ -159,7 +156,7 @@ impl Mpd {
} else if buffer.starts_with("ACK") {
break Err(anyhow!(buffer));
} else {
dbg!(&buffer);
println!("Unexpected MPD response {buffer}");
}
}
}
@ -246,7 +243,7 @@ impl Mpd {
}
}
#[allow(clippy::manual_map)]
pub async fn ls(&mut self, path: &str) -> anyhow::Result<Vec<Entry>> {
fn get_filename(path: &str) -> String {
std::path::Path::new(path)
@ -256,7 +253,7 @@ impl Mpd {
}
let result = self
.command(&format!("lsinfo \"{}\"", Self::escape_str(&path)))
.command(&format!("lsinfo \"{}\"", Self::escape_str(path)))
.await?
.into_hashmaps(&["file", "directory", "playlist"]);
@ -265,18 +262,18 @@ impl Mpd {
.flat_map(|prop| {
if let Some(file) = prop.get("file") {
Some(Entry::Song {
name: prop.get("Title").unwrap_or(&get_filename(&file)).clone(),
name: prop.get("Title").unwrap_or(&get_filename(file)).clone(),
artist: prop.get("Artist").unwrap_or(&String::new()).clone(),
path: file.to_string(),
})
} else if let Some(file) = prop.get("directory") {
Some(Entry::Directory {
name: get_filename(&file),
name: get_filename(file),
path: file.to_string(),
})
} else if let Some(file) = prop.get("playlist") {
Some(Entry::Playlist {
name: get_filename(&file),
name: get_filename(file),
path: file.to_string(),
})
} else {