From 3578eae01a8d5a537cff3ad47105bc340b081fe7 Mon Sep 17 00:00:00 2001 From: krolxon Date: Mon, 22 Apr 2024 14:46:12 +0530 Subject: [PATCH] remove this absolute brainfuck of a function, what the fuck --- src/connection.rs | 29 ++++++----------------------- 1 file 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 { let mut conn = Client::connect(addrs)?; - let mut songs_filenames: Vec = Vec::new(); - get_file_tree_into_vec(&mut conn, &mut songs_filenames, ".", "."); + let songs_filenames: Vec = 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, 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::().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, selection: &str) -> usize { let mut choice: usize = 0; if let Some(index) = ss.iter().position(|s| s == selection) {