Warning changes
This commit is contained in:
@@ -34,10 +34,7 @@ pub mod test_util {
|
||||
let src_path = std::path::Path::new(source_path);
|
||||
let dest_path = std::path::Path::new(destination_path);
|
||||
|
||||
match std::fs::copy(src_path, dest_path) {
|
||||
Ok(bytes) => Ok(bytes),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
std::fs::copy(src_path, dest_path)
|
||||
}
|
||||
|
||||
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
|
||||
|
@@ -278,12 +278,11 @@ mod tests {
|
||||
|
||||
// use super::*;
|
||||
|
||||
|
||||
mod get {
|
||||
use super::super::metadata::get_meta;
|
||||
use crate::types;
|
||||
use crate::test_util::util;
|
||||
use crate::test_util::util::{file_exists, get_full_path};
|
||||
use crate::types;
|
||||
|
||||
#[test]
|
||||
fn test_get_title() {
|
||||
@@ -537,9 +536,9 @@ mod tests {
|
||||
|
||||
mod set {
|
||||
use super::super::metadata::{get_meta, set_meta};
|
||||
use crate::types;
|
||||
use crate::test_util::util;
|
||||
use crate::test_util::util::{file_exists, get_full_path};
|
||||
use crate::types;
|
||||
|
||||
#[test]
|
||||
fn test_set_title() {
|
||||
|
@@ -2,23 +2,22 @@ use lofty::file::AudioFile;
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Duration {
|
||||
pub val: i32
|
||||
pub val: i32,
|
||||
}
|
||||
|
||||
pub fn get_duration(song_path: &String) -> Result<std::time::Duration,std::io::Error> {
|
||||
pub fn get_duration(song_path: &String) -> Result<std::time::Duration, std::io::Error> {
|
||||
match std::fs::File::open(song_path) {
|
||||
Ok(mut content) => match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new(),) {
|
||||
Ok(flac_file) => {
|
||||
let properties = flac_file.properties();
|
||||
Ok(properties.duration())
|
||||
}
|
||||
Err(err) => {
|
||||
Err(std::io::Error::other(err.to_string()))
|
||||
Ok(mut content) => {
|
||||
match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new())
|
||||
{
|
||||
Ok(flac_file) => {
|
||||
let properties = flac_file.properties();
|
||||
Ok(properties.duration())
|
||||
}
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
Err(err)
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +38,10 @@ mod tests {
|
||||
let song_duration: u64 = 41;
|
||||
let fetched_song_duration = duration.as_secs();
|
||||
|
||||
assert_eq!(song_duration, fetched_song_duration, "Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})");
|
||||
assert_eq!(
|
||||
song_duration, fetched_song_duration,
|
||||
"Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
|
Reference in New Issue
Block a user