Commit c3d836e3 authored by Felix Häcker's avatar Felix Häcker

Merge branch 'longtrack-fix' into 'master'

fix #507 - the crash caused by long track title

Closes #507

See merge request !401
parents a047cdc1 85be1ef4
Pipeline #218569 failed with stages
in 44 seconds
......@@ -386,7 +386,12 @@ impl SongTitle {
/// Returns path for current title
fn get_path(&self) -> Option<PathBuf> {
if let Some(title) = &self.current_title {
let title = utils::simplify_string(title.to_string());
// Remove unsupported characters from the file name
let title_raw = utils::simplify_string(title.to_string());
// Limit file name to 200 chars
let title_vec = title_raw.chars().collect::<Vec<_>>();
let cut_to_length = title_vec.len().min(200);
let title = text_vec[..cut_to_length].iter().cloned().collect::<String>();
let mut path = path::CACHE.clone();
path.push("recording");
......
......@@ -96,7 +96,7 @@ where
}
pub fn simplify_string(s: String) -> String {
s.replace(&['/', '\\', ':', '<', '>', '\"', '|', '?', '*', '.'] as &[_], "")
s.replace(&['/', '\\0', '\\', ':', '<', '>', '\"', '|', '?', '*', '.'] as &[_], "")
}
pub fn station_subtitle(country: &str, state: &str, votes: i32) -> String {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment