fix: panic if track number is none
This commit is contained in:
+11
-7
@@ -36,12 +36,16 @@ pub fn move_files(
|
||||
create_dir_all(&dir_to_create)?;
|
||||
let target = target_dir.join(artist_dir).join(album_dir.as_ref());
|
||||
|
||||
let file_name = PathBuf::from(format!(
|
||||
"0{}. {} - {}.flac",
|
||||
track_number.unwrap(),
|
||||
artist.unwrap(),
|
||||
title.unwrap(),
|
||||
));
|
||||
let file_name = if let Some(track_number) = track_number {
|
||||
PathBuf::from(format!(
|
||||
"{:02}. {} - {}.flac",
|
||||
track_number,
|
||||
artist.unwrap(),
|
||||
title.unwrap(),
|
||||
))
|
||||
} else {
|
||||
PathBuf::from(format!("01. {} - {}.flac", artist.unwrap(), title.unwrap(),))
|
||||
};
|
||||
|
||||
if should_copy {
|
||||
copy(&file_path, target.join(file_name))?;
|
||||
@@ -72,6 +76,6 @@ pub fn move_files(
|
||||
remove_dir(file_path.parent().unwrap())?;
|
||||
}
|
||||
|
||||
println!("Imported file: {:?}", file_path.file_name().unwrap());
|
||||
//println!("Imported file: {:?}", file_path.file_name().unwrap());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user