diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-04-22 14:46:12 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-04-22 14:46:12 +0530 |
| commit | 3578eae01a8d5a537cff3ad47105bc340b081fe7 (patch) | |
| tree | 19051bf5c7b1b9cf13d908c1d721d1c51c203b1a | |
| parent | bc0348ec5bd07c656509ca1312b3a42ffba175d2 (diff) | |
remove this absolute brainfuck of a function, what the fuck
| -rwxr-xr-x | src/connection.rs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/src/connection.rs b/src/connection.rs index 96545de..06ae752 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -10,8 +10,12 @@ pub struct Connection { impl Connection { pub fn new(addrs: &str) -> Result<Self, mpd::error::Error> { let mut conn = Client::connect(addrs)?; - let mut songs_filenames: Vec<String> = Vec::new(); - get_file_tree_into_vec(&mut conn, &mut songs_filenames, ".", "."); + let songs_filenames: Vec<String> = conn + .listall() + .unwrap() + .iter() + .map(|x| x.clone().file) + .collect(); Ok(Self { conn, @@ -99,27 +103,6 @@ impl Connection { } } -fn get_file_tree_into_vec(conn: &mut Client, vec: &mut Vec<String>, path: &str, dir_append: &str) { - let songs = conn.listfiles(path).unwrap_or_default(); - for (i, s) in songs { - // Output of listfiles contains the last-modified thing, we dont want that - if i != "Last-Modified" { - if i == "directory" { - get_file_tree_into_vec(conn, vec, &s, &s); - } else { - // We parse the string as float because the output of listfiles contains some random numbers, we dont want that - if !s.parse::<f32>().is_ok() { - let mut sam: String = String::new(); - sam.push_str(dir_append); - sam.push_str(r"/"); - sam.push_str(s.as_str()); - vec.push(sam); - } - } - } - } -} - fn get_choice_index(ss: &Vec<String>, selection: &str) -> usize { let mut choice: usize = 0; if let Some(index) = ss.iter().position(|s| s == selection) { |
