aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-05-30 16:36:04 +0530
committerkrolxon <krolyxon@tutanota.com>2024-05-30 16:36:04 +0530
commit7b14b6816487117bb960d1553879b8663d07103b (patch)
tree9ecd8f1a23b0bb7a33288b4cf59b52442886fa61
parent6ae0aca8680d2ffd36442e58e5ab8b1d1b083d15 (diff)
workaround for #7, fix error when using 'Space'
-rwxr-xr-xsrc/app.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/app.rs b/src/app.rs
index 6344799..491112f 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,6 +1,6 @@
-use std::time::Duration;
+use std::{path::Path, time::Duration};
-use crate::browser::FileBrowser;
+use crate::browser::{FileBrowser, FileExtension};
use crate::connection::Connection;
use crate::list::ContentList;
use crate::ui::InputMode;
@@ -117,14 +117,15 @@ impl App {
let songs = self.conn.conn.listfiles(&file).unwrap_or_default();
for (t, f) in songs.iter() {
if t == "file" {
- let path = self.browser.prev_path.to_string()
- + "/"
- + self.browser.path.as_str()
- + "/"
- + f;
- let full_path = path.strip_prefix("./").unwrap_or_else(|| "");
- let song = self.conn.get_song_with_only_filename(full_path);
- self.conn.conn.push(&song)?;
+ if Path::new(&f).has_extension(&[
+ "mp3", "ogg", "flac", "m4a", "wav", "aac", "opus", "ape", "wma",
+ "mpc", "aiff", "dff", "mp2", "mka",
+ ]) {
+ let path = file.clone() + "/" + f;
+ let full_path = path.strip_prefix("./").unwrap_or_else(|| "");
+ let song = self.conn.get_song_with_only_filename(&full_path);
+ self.conn.conn.push(&song)?;
+ }
}
}
} else if content_type == "file" {
@@ -143,7 +144,7 @@ impl App {
+ self.browser.path.as_str()
+ "/"
+ content;
- let full_path = path.strip_prefix("./").unwrap_or_else(|| "");
+ let full_path = path.strip_prefix("././").unwrap_or_else(|| "");
let song = self.conn.get_song_with_only_filename(full_path);
self.conn.conn.push(&song)?;