Code cleanup
This commit is contained in:
13
src/song.rs
13
src/song.rs
@@ -114,25 +114,18 @@ impl Song {
|
|||||||
let p = std::path::Path::new(&song_path);
|
let p = std::path::Path::new(&song_path);
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
match std::fs::remove_file(&p) {
|
match std::fs::remove_file(&p) {
|
||||||
Ok(_) => {
|
Ok(_) => Ok(()),
|
||||||
Ok(())
|
Err(err) => Err(err),
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => Err(err),
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Generates a filename. In order to save a song to the filesystem, the song must have
|
/// Generates a filename. In order to save a song to the filesystem, the song must have
|
||||||
/// a directory and filename
|
/// a directory and filename
|
||||||
pub fn generate_filename(typ: types::MusicTypes, randomize: bool) -> String {
|
pub fn generate_filename(typ: types::MusicTypes, randomize: bool) -> String {
|
||||||
|
@@ -132,15 +132,12 @@ mod song_tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
match song::io::copy_song(&song, &mut copied_song) {
|
match song::io::copy_song(&song, &mut copied_song) {
|
||||||
Ok(_) => {
|
Ok(_) => match copied_song.remove_from_filesystem() {
|
||||||
match copied_song.remove_from_filesystem() {
|
Ok(_) => {}
|
||||||
Ok(_) => {
|
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {err:?}")
|
assert!(false, "Error: {err:?}")
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
assert!(false, "Error: {err:?}")
|
assert!(false, "Error: {err:?}")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user