rmptuie181181
workaround for #7, fix error when using 'Space'
+12 −11
1 file changed
- M src/app.rs +12 −11
| @@ -1,6 +1,6 @@ | |||
| 1 | − | use std::time::Duration; | |
| 1 | + | use std::{path::Path, time::Duration}; | |
| 2 | 2 | ||
| 3 | − | use crate::browser::FileBrowser; | |
| 3 | + | use crate::browser::{FileBrowser, FileExtension}; | |
| 4 | 4 | use crate::connection::Connection; | |
| 5 | 5 | use crate::list::ContentList; | |
| 6 | 6 | use crate::ui::InputMode; | |
| @@ -117,14 +117,15 @@ impl App { | |||
| 117 | 117 | let songs = self.conn.conn.listfiles(&file).unwrap_or_default(); | |
| 118 | 118 | for (t, f) in songs.iter() { | |
| 119 | 119 | if t == "file" { | |
| 120 | − | let path = self.browser.prev_path.to_string() | |
| 121 | − | + "/" | |
| 122 | − | + self.browser.path.as_str() | |
| 123 | − | + "/" | |
| 124 | − | + f; | |
| 125 | − | let full_path = path.strip_prefix("./").unwrap_or_else(|| ""); | |
| 126 | − | let song = self.conn.get_song_with_only_filename(full_path); | |
| 127 | − | self.conn.conn.push(&song)?; | |
| 120 | + | if Path::new(&f).has_extension(&[ | |
| 121 | + | "mp3", "ogg", "flac", "m4a", "wav", "aac", "opus", "ape", "wma", | |
| 122 | + | "mpc", "aiff", "dff", "mp2", "mka", | |
| 123 | + | ]) { | |
| 124 | + | let path = file.clone() + "/" + f; | |
| 125 | + | let full_path = path.strip_prefix("./").unwrap_or_else(|| ""); | |
| 126 | + | let song = self.conn.get_song_with_only_filename(&full_path); | |
| 127 | + | self.conn.conn.push(&song)?; | |
| 128 | + | } | |
| 128 | 129 | } | |
| 129 | 130 | } | |
| 130 | 131 | } else if content_type == "file" { | |
| @@ -143,7 +144,7 @@ impl App { | |||
| 143 | 144 | + self.browser.path.as_str() | |
| 144 | 145 | + "/" | |
| 145 | 146 | + content; | |
| 146 | − | let full_path = path.strip_prefix("./").unwrap_or_else(|| ""); | |
| 147 | + | let full_path = path.strip_prefix("././").unwrap_or_else(|| ""); | |
| 147 | 148 | ||
| 148 | 149 | let song = self.conn.get_song_with_only_filename(full_path); | |
| 149 | 150 | self.conn.conn.push(&song)?; | |