summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 0c65b30..0dc65bc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ use std::{env, fs::{self, File}, path::Path, fmt::format, os::fd::IntoRawFd};
use std::io::{Error, ErrorKind, BufReader, Read};
use lofty::{Probe, TaggedFileExt, LoftyError, TagExt, Tag, Picture, Accessor, PictureType};
use clap::Parser;
+use rayon::prelude::*;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
@@ -121,15 +122,20 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("💡 Start scanning \"{}\" dir for ogg file", music_path.as_str());
- for entry in music_dir {
- let path = entry?.path();
+
+ let paths: Vec<_> = music_dir.filter_map(Result::ok)
+ .map(|entry| entry.path())
+ .filter(|path| path.extension().and_then(std::ffi::OsStr::to_str) == Some("ogg"))
+ .collect();
+
+ paths.par_iter().for_each(|path| {
if path.is_file() {
- // Improved error handling
- if let Err(e) = tag_ogg_file(&path) {
+ if let Err(e) = tag_ogg_file(path) {
eprintln!("🔥 Error tagging file {:?}: {}", path, e);
}
}
- }
+ });
+
println!("💡 Ended successfully");
Ok(())
Software created with 💖