summaryrefslogtreecommitdiff
path: root/src/files.rs
diff options
context:
space:
mode:
authorjakka <jakkadoujin@gmail.com>2025-07-02 12:00:11 +0300
committerjakka <jakkadoujin@gmail.com>2025-07-02 12:00:11 +0300
commit04208aad8ec925f27938419b066f92861dc40f34 (patch)
tree1087fe4478c9d6348e8a730093b61828b361c4b5 /src/files.rs
parentd0c67d99c4f7ac4f90e244ae1a7afee595c396a9 (diff)
continued working
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/files.rs b/src/files.rs
index 29cd2a9..da2c911 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -101,46 +101,45 @@ pub fn index_files_recursively(
let (tx, rx) = mpsc::channel();
let ex = Executor::new();
- WalkDir::new(abspath)
- .into_iter()
- .par_bridge()
- .for_each(|entry| {
- if running.load(Ordering::SeqCst) {
- let path = entry.unwrap().into_path();
- if !path.is_file() {
- return;
- }
- if path.extension().is_some_and(|x| x == "flac") {
- let newconn = conn.clone();
- let newrunning = running.clone();
- let newtx = tx.clone();
- #[cfg(not(test))]
- let newbar = bar.clone();
+ for entry in WalkDir::new(abspath) {
+ if running.load(Ordering::SeqCst) {
+ let path = entry.unwrap().into_path();
+ if !path.is_file() {
+ continue;
+ }
+ if path.extension().is_some_and(|x| x == "flac") {
+ let newconn = conn.clone();
+ let newrunning = running.clone();
+ let newtx = tx.clone();
+ #[cfg(not(test))]
+ let newbar = bar.clone();
- ex.spawn(async move {
- if !newrunning.load(Ordering::SeqCst) {
- match handle_file(&path, newconn).await {
- Err(error) => newtx.send(FileError::new(path, error)),
- Ok(_) => {
- #[cfg(not(test))]
- newbar.inc(1);
- Ok(())
- }
+ ex.spawn(async move {
+ if !newrunning.load(Ordering::SeqCst) {
+ match handle_file(&path, newconn).await {
+ Err(error) => newtx.send(FileError::new(path, error)),
+ Ok(_) => {
+ #[cfg(not(test))]
+ newbar.inc(1);
+ Ok(())
}
- } else {
- Ok(())
}
- })
- .detach();
+ } else {
+ Ok(())
+ }
+ })
+ .detach();
- #[cfg(not(test))]
- bar.inc_length(1);
- }
+ #[cfg(not(test))]
+ bar.inc_length(1);
}
- });
+ }
+ }
- while let Ok(message) = rx.recv() {
- eprintln!("{}", message);
+ while !ex.is_empty() {
+ if let Ok(message) = rx.recv() {
+ eprintln!("{}", message);
+ }
}
#[cfg(not(test))]