Krolyxon
Commit 06da8f0

rmptui06da8f0

workaround for #7

Author
krolxon
Date
2024-05-25 11:09 +0530
Parent
a761500
Commit
06da8f078de0a7af9da80fbdadcfa7c3ccccb04b

+21 −11

2 files changed

  1. M src/app.rs +17 −8
  2. M src/browser.rs +4 −3
M src/app.rs View
@@ -117,10 +117,14 @@ 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− if let Some(full_path) = &self.conn.get_full_path(f) {
121− let song = self.conn.get_song_with_only_filename(full_path);
122− self.conn.conn.push(&song)?;
123− }
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)?;
124128 }
125129 }
126130 } else if content_type == "file" {
@@ -134,10 +138,15 @@ impl App {
134138 }
135139
136140 if !status {
137− if let Some(full_path) = &self.conn.get_full_path(content) {
138− let song = self.conn.get_song_with_only_filename(full_path);
139− self.conn.conn.push(&song)?;
140− }
141+ let path = self.browser.prev_path.to_string()
142+ + "/"
143+ + self.browser.path.as_str()
144+ + "/"
145+ + content;
146+ let full_path = path.strip_prefix("./").unwrap_or_else(|| "");
147+
148+ let song = self.conn.get_song_with_only_filename(full_path);
149+ self.conn.conn.push(&song)?;
141150 }
142151 }
143152
M src/browser.rs View
@@ -89,9 +89,10 @@ impl FileBrowser {
8989 let v = conn
9090 .conn
9191 .lsinfo(Song {
92− file: conn
93− .get_full_path(song)
94− .unwrap_or_else(|| "Not a song".to_string()),
92+ file: (self.path.clone() + "/" + song)
93+ .strip_prefix("./")
94+ .unwrap_or_else(|| "")
95+ .to_string(),
9596 ..Default::default()
9697 })
9798 .unwrap_or_else(|_| {