aboutsummaryrefslogtreecommitdiff
path: root/src/connection.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-28 23:59:42 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-28 23:59:42 +0530
commit6b66a44ed035c33c43377a63b23856923743ea09 (patch)
treef721d81326b096b0f8bc59b1354dc3299280a6e4 /src/connection.rs
parent66a1cfccf46acc505c04dc4048d1a0ef6f8cbeea (diff)
fix queue deletion & make get_full_path return an option
Diffstat (limited to 'src/connection.rs')
-rwxr-xr-xsrc/connection.rs30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/connection.rs b/src/connection.rs
index 1ec76ae..8f4fe72 100755
--- a/src/connection.rs
+++ b/src/connection.rs
@@ -188,18 +188,26 @@ impl Connection {
}
/// Given a song name from a directory, it returns the full path of the song in the database
- pub fn get_full_path(&self, short_path: &str) -> AppResult<String> {
- let list = self
- .songs_filenames
- .iter()
- .map(|f| f.as_str())
- .collect::<Vec<&str>>();
- let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted(&short_path, &list)
- .get(0)
- .unwrap()
- .clone();
+ pub fn get_full_path(&self, short_path: &str) -> Option<String> {
+ // let list = self
+ // .songs_filenames
+ // .iter()
+ // .map(|f| f.as_str())
+ // .collect::<Vec<&str>>();
+ // let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted(&short_path, &list)
+ // .get(0)
+ // .unwrap()
+ // .clone();
+
+ for (i, f) in self.songs_filenames.iter().enumerate() {
+ if f.contains(short_path) {
+ return Some(self.songs_filenames.get(i).unwrap().to_string());
+ }
+ }
+
+ None
- Ok(filename.to_string())
+ // Ok(filename.to_string())
}
/// Print status to stdout