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,12 +277,14 @@ 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 {
if ilias.opt.check_videos {
let head = ilias.client.head(url).send().await.context("HEAD request failed")?; let head = ilias.client.head(url).send().await.context("HEAD request failed")?;
if let Some(len) = head.headers().get("content-length") { if let Some(len) = head.headers().get("content-length") {
if meta.len() != len.to_str()?.parse::<u64>()? { if meta.len() != len.to_str()?.parse::<u64>()? {
log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy()); 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");
if !ilias.opt.force { if !ilias.opt.force {
return Ok(()); return Ok(());
@ -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,