Make OpenCast lecture update checks optional

This commit is contained in:
FliegendeWurst 2020-06-23 16:42:15 +02:00
parent 7cc780ed18
commit 67ba34af85

View File

@ -277,10 +277,12 @@ fn process(ilias: Arc<ILIAS>, mut path: PathBuf, obj: Object) -> impl Future<Out
.ok_or(anyhow!("video src not found"))? .ok_or(anyhow!("video src not found"))?
.ok_or(anyhow!("video src not string"))?; .ok_or(anyhow!("video src not string"))?;
if let Ok(meta) = fs::metadata(&path).await { if let Ok(meta) = fs::metadata(&path).await {
let head = ilias.client.head(url).send().await.context("HEAD request failed")?; if ilias.opt.check_videos {
if let Some(len) = head.headers().get("content-length") { let head = ilias.client.head(url).send().await.context("HEAD request failed")?;
if meta.len() != len.to_str()?.parse::<u64>()? { if let Some(len) = head.headers().get("content-length") {
log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy()); if meta.len() != len.to_str()?.parse::<u64>()? {
log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy());
}
} }
} }
log!(2, "Skipping download, file exists already"); log!(2, "Skipping download, file exists already");
@ -500,6 +502,10 @@ struct Opt {
#[structopt(long)] #[structopt(long)]
content_tree: bool, content_tree: bool,
/// Re-check OpenCast lectures (slow)
#[structopt(long)]
check_videos: bool,
/// Verbose logging (print objects downloaded) /// Verbose logging (print objects downloaded)
#[structopt(short, multiple = true, parse(from_occurrences))] #[structopt(short, multiple = true, parse(from_occurrences))]
verbose: usize, verbose: usize,