From 620a6af0a247ed1675477b86f77c07c55d9feea3 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 24 Jan 2024 14:19:51 +0100 Subject: recursive media import ignores by extension --- import/src/lib.rs | 56 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'import/src') diff --git a/import/src/lib.rs b/import/src/lib.rs index 678d065..d1605fe 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -400,33 +400,37 @@ async fn process_source( for f in media_path.read_dir()? { let f = f?; let child_path = f.path(); - let inf_id = infer_id_from_path(&child_path).context("inferring child id")?; - - if &inf_id == "archive" { - continue; - } - process_source( - inf_id.clone(), - ImportSource::Media { - location: match &location { - AssetLocation::Media(p) => { - AssetLocation::Media(p.join(f.file_name())) - } - _ => bail!("non media path media"), + if child_path.is_dir() + || matches!( + child_path.extension().map(|o| o.to_str().unwrap()), + Some("mks" | "mka" | "mkv" | "webm") + ) + { + let inf_id = + infer_id_from_path(&child_path).context("inferring child id")?; + process_source( + inf_id.clone(), + ImportSource::Media { + location: match &location { + AssetLocation::Media(p) => { + AssetLocation::Media(p.join(f.file_name())) + } + _ => bail!("non media path media"), + }, + ignore_attachments, + ignore_chapters, + ignore_metadata, }, - ignore_attachments, - ignore_chapters, - ignore_metadata, - }, - path, - index_path, - db, - fed, - ap, - ) - .await - .context(anyhow!("recursive media import: {:?}", f.path()))?; - node.public.children.push(inf_id); + path, + index_path, + db, + fed, + ap, + ) + .await + .context(anyhow!("recursive media import: {:?}", f.path()))?; + node.public.children.push(inf_id); + } } insert_node(&id, node)?; } else if media_path.is_file() { -- cgit v1.2.3-70-g09d2