From d5cc512a7e8eddcd0de3e45df44f40dcdd0bb90a Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Fri, 11 Jun 2021 15:06:16 +0200 Subject: [PATCH] Skip downloading zip of forum post attachments --- src/ilias/thread.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ilias/thread.rs b/src/ilias/thread.rs index b09cd45..bc48381 100644 --- a/src/ilias/thread.rs +++ b/src/ilias/thread.rs @@ -79,10 +79,15 @@ pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: } if let Some(container) = container.select(&POST_ATTACHMENTS).next() { for attachment in container.select(&LINKS) { + let href = attachment.value().attr("href").map(|x| x.to_owned()) + .context("attachment link without href")?; + if href.contains("cmd=deliverZipFile") { + continue; // skip downloading all attachments as zip + } attachments.push(( id.clone(), attachment.text().collect::(), - attachment.value().attr("href").map(|x| x.to_owned()), + href, )); } } @@ -132,7 +137,6 @@ pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: })); } for (id, name, url) in attachments { - let url = url.context("attachment without href")?; let src = URL::from_href(&url)?; let dl = ilias.download(&src.url).await?; let mut path = path.to_owned();