summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/files.rs35
-rw-r--r--src/main.rs2
2 files changed, 17 insertions, 20 deletions
diff --git a/src/files.rs b/src/files.rs
index 8b089e8..c5583ee 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -90,17 +90,13 @@ pub fn index_files_recursively(
.with_style(ProgressStyle::with_template(BAR_TEMPLATE)?.progress_chars("#>-"))
.with_message("Indexing");
- let mut paths = Vec::new();
-
- for entry in WalkDir::new(abspath) {
+ for entry in WalkDir::new(&abspath) {
if handler.load(Ordering::SeqCst) {
let path = entry.unwrap().into_path();
if !path.is_file() {
continue;
}
if path.extension().is_some_and(|x| x == "flac") {
- paths.push(path);
-
#[cfg(not(test))]
bar.inc_length(1);
}
@@ -109,24 +105,25 @@ pub fn index_files_recursively(
}
}
- paths.par_iter().for_each(|file| {
+ let conn = Database::new(pool.get()?);
+ for entry in WalkDir::new(abspath) {
if handler.load(Ordering::SeqCst) {
- let conn = match pool.get() {
- Ok(conn) => Database::new(conn),
- Err(error) => {
- eprintln!("{}", FileError::new(file, error.into()));
- return;
+ let path = entry.unwrap().into_path();
+ if !path.is_file() {
+ continue;
+ }
+ if path.extension().is_some_and(|x| x == "flac") {
+ if let Err(error) = handle_file(&path, &conn) {
+ eprintln!("{}", FileError::new(path, error));
+ } else {
+ #[cfg(not(test))]
+ bar.inc(1);
}
- };
-
- if let Err(error) = handle_file(file, &conn) {
- eprintln!("{}", FileError::new(file, error))
- } else {
- #[cfg(not(test))]
- bar.inc(1);
}
+ } else {
+ break;
}
- });
+ }
#[cfg(not(test))]
{
diff --git a/src/main.rs b/src/main.rs
index 6d0a3d4..1363a77 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -111,7 +111,7 @@ fn main() -> Result<()> {
if let Some(realpath) = path {
let hanlder = running.clone();
- pool.install(|| files::index_files_recursively(realpath, &dbpool, hanlder))?;
+ files::index_files_recursively(realpath, &dbpool, hanlder)?;
}
if args.get_flag("clean") {