Skip downloading zip of forum post attachments

This commit is contained in:
FliegendeWurst 2021-06-11 15:06:16 +02:00
parent e4015e723d
commit d5cc512a7e

View File

@ -79,10 +79,15 @@ pub async fn download(path: &Path, relative_path: &Path, ilias: Arc<ILIAS>, url:
} }
if let Some(container) = container.select(&POST_ATTACHMENTS).next() { if let Some(container) = container.select(&POST_ATTACHMENTS).next() {
for attachment in container.select(&LINKS) { 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(( attachments.push((
id.clone(), id.clone(),
attachment.text().collect::<String>(), attachment.text().collect::<String>(),
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<ILIAS>, url:
})); }));
} }
for (id, name, url) in attachments { for (id, name, url) in attachments {
let url = url.context("attachment without href")?;
let src = URL::from_href(&url)?; let src = URL::from_href(&url)?;
let dl = ilias.download(&src.url).await?; let dl = ilias.download(&src.url).await?;
let mut path = path.to_owned(); let mut path = path.to_owned();