Krolyxon
Commit e181181

rmptuie181181

workaround for #7, fix error when using 'Space'

Author
krolxon
Date
2024-05-30 16:36 +0530
Parent
2aa98fa
Commit
e1811818a9a3739f42d1e546c4fcadce6318a08e

+12 −11

1 file changed

  1. M src/app.rs +12 −11
M src/app.rs View
@@ -1,6 +1,6 @@
1−use std::time::Duration;
1+use std::{path::Path, time::Duration};
22
3−use crate::browser::FileBrowser;
3+use crate::browser::{FileBrowser, FileExtension};
44 use crate::connection::Connection;
55 use crate::list::ContentList;
66 use crate::ui::InputMode;
@@ -117,14 +117,15 @@ impl App {
117117 let songs = self.conn.conn.listfiles(&file).unwrap_or_default();
118118 for (t, f) in songs.iter() {
119119 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+ }
128129 }
129130 }
130131 } else if content_type == "file" {
@@ -143,7 +144,7 @@ impl App {
143144 + self.browser.path.as_str()
144145 + "/"
145146 + content;
146− let full_path = path.strip_prefix("./").unwrap_or_else(|| "");
147+ let full_path = path.strip_prefix("././").unwrap_or_else(|| "");
147148
148149 let song = self.conn.get_song_with_only_filename(full_path);
149150 self.conn.conn.push(&song)?;