fix: panic if track number is none
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
/target
|
||||
/test
|
||||
/.direnv
|
||||
*.flac
|
||||
*.mp3
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
buildInputs = [
|
||||
rust
|
||||
cargo-nextest
|
||||
fish
|
||||
];
|
||||
|
||||
env.RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
@@ -52,7 +51,6 @@
|
||||
|
||||
shellHook = ''
|
||||
echo Entered Rust dev shell for project music-sort
|
||||
exec fish
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
+9
-5
@@ -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(),
|
||||
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