rmptui3578eae
remove this absolute brainfuck of a function, what the fuck
+6 −23
1 file changed
- M src/connection.rs +6 −23
| @@ -10,8 +10,12 @@ pub struct Connection { | |||
| 10 | 10 | impl Connection { | |
| 11 | 11 | pub fn new(addrs: &str) -> Result<Self, mpd::error::Error> { | |
| 12 | 12 | let mut conn = Client::connect(addrs)?; | |
| 13 | − | let mut songs_filenames: Vec<String> = Vec::new(); | |
| 14 | − | get_file_tree_into_vec(&mut conn, &mut songs_filenames, ".", "."); | |
| 13 | + | let songs_filenames: Vec<String> = conn | |
| 14 | + | .listall() | |
| 15 | + | .unwrap() | |
| 16 | + | .iter() | |
| 17 | + | .map(|x| x.clone().file) | |
| 18 | + | .collect(); | |
| 15 | 19 | ||
| 16 | 20 | Ok(Self { | |
| 17 | 21 | conn, | |
| @@ -99,27 +103,6 @@ impl Connection { | |||
| 99 | 103 | } | |
| 100 | 104 | } | |
| 101 | 105 | ||
| 102 | − | fn get_file_tree_into_vec(conn: &mut Client, vec: &mut Vec<String>, path: &str, dir_append: &str) { | |
| 103 | − | let songs = conn.listfiles(path).unwrap_or_default(); | |
| 104 | − | for (i, s) in songs { | |
| 105 | − | // Output of listfiles contains the last-modified thing, we dont want that | |
| 106 | − | if i != "Last-Modified" { | |
| 107 | − | if i == "directory" { | |
| 108 | − | get_file_tree_into_vec(conn, vec, &s, &s); | |
| 109 | − | } else { | |
| 110 | − | // We parse the string as float because the output of listfiles contains some random numbers, we dont want that | |
| 111 | − | if !s.parse::<f32>().is_ok() { | |
| 112 | − | let mut sam: String = String::new(); | |
| 113 | − | sam.push_str(dir_append); | |
| 114 | − | sam.push_str(r"/"); | |
| 115 | − | sam.push_str(s.as_str()); | |
| 116 | − | vec.push(sam); | |
| 117 | − | } | |
| 118 | − | } | |
| 119 | − | } | |
| 120 | − | } | |
| 121 | − | } | |
| 122 | − | ||
| 123 | 106 | fn get_choice_index(ss: &Vec<String>, selection: &str) -> usize { | |
| 124 | 107 | let mut choice: usize = 0; | |
| 125 | 108 | if let Some(index) = ss.iter().position(|s| s == selection) { | |