From 67ba34af85498c912bdcf4757b19ae57e29761a4 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu@web.de> Date: Tue, 23 Jun 2020 16:42:15 +0200 Subject: [PATCH] Make OpenCast lecture update checks optional --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9fcbb36..6d0ed77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -277,10 +277,12 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future()? { - log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy()); + if ilias.opt.check_videos { + let head = ilias.client.head(url).send().await.context("HEAD request failed")?; + if let Some(len) = head.headers().get("content-length") { + if meta.len() != len.to_str()?.parse::()? { + log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy()); + } } } log!(2, "Skipping download, file exists already"); @@ -500,6 +502,10 @@ struct Opt { #[structopt(long)] content_tree: bool, + /// Re-check OpenCast lectures (slow) + #[structopt(long)] + check_videos: bool, + /// Verbose logging (print objects downloaded) #[structopt(short, multiple = true, parse(from_occurrences))] verbose: usize,