diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3884c2f..812ddc0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -132,6 +132,16 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.9 + - name: Update Rust + # print it with style + run: | + printf '*%.0s' {1..60} && printf "\n" + echo "Existing rust version: $(rustc --version)" + printf '*%.0s' {1..60} && printf "\n\n" + rustup update && printf "\n" + printf '*%.0s' {1..60} && printf "\n" + echo "Updated rust version: $(rustc --version)" + printf '*%.0s' {1..60} && printf "\n" - name: Install OpenSSL static for Windows # https://github.com/sfackler/rust-openssl/issues/1086 diff --git a/src/routes/auth.rs b/src/routes/auth.rs index 4285149..b64fcb3 100644 --- a/src/routes/auth.rs +++ b/src/routes/auth.rs @@ -102,9 +102,17 @@ pub async fn home(config: web::Data>, } squire::logger::log_connection(&request); log::debug!("{}", auth_response.detail); + let default_values = squire::settings::default_file_formats(); + let file_format; // https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.collect_tuple - let file_format = config.file_formats.iter().collect_tuple().unwrap(); - let args = (config.video_source.to_string_lossy().to_string(), file_format); + let _file_format = config.file_formats.iter().collect_tuple(); + if _file_format.is_none() { + log::debug!("CRITICAL::Failed to extract tuple from {:?}", config.file_formats); + file_format = default_values.iter().collect_tuple(); + } else { + file_format = _file_format + } + let args = (config.video_source.to_string_lossy().to_string(), file_format.unwrap()); let listing_page = squire::fileio::get_all_stream_content(args); let template = constant::ENV.lock().unwrap(); let listing = template.get_template("listing").unwrap(); diff --git a/src/routes/video.rs b/src/routes/video.rs index 59e8ea7..4b195ca 100644 --- a/src/routes/video.rs +++ b/src/routes/video.rs @@ -90,8 +90,17 @@ pub async fn stream(config: web::Data>, let template = constant::ENV.lock().unwrap(); if target.is_file() { let landing = template.get_template("landing").unwrap(); - let file_format = config.file_formats.iter().collect_tuple().unwrap(); - let args = (&target_str, file_format); + let default_values = squire::settings::default_file_formats(); + let file_format; + // https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.collect_tuple + let _file_format = config.file_formats.iter().collect_tuple(); + if _file_format.is_none() { + log::debug!("CRITICAL::Failed to extract tuple from {:?}", config.file_formats); + file_format = default_values.iter().collect_tuple(); + } else { + file_format = _file_format + } + let args = (&target_str, file_format.unwrap()); let iter = squire::fileio::get_iter(args); // https://rustjobs.dev/blog/how-to-url-encode-strings-in-rust/ let render_path = format!("/video?file={}", @@ -127,8 +136,17 @@ pub async fn stream(config: web::Data>, .content_type("text/html; charset=utf-8").body(response_body); } else if target.is_dir() { let child_dir = target.iter().last().unwrap().to_string_lossy().to_string(); - let file_format = config.file_formats.iter().collect_tuple().unwrap(); - let args = (target_str, child_dir, file_format); + let default_values = squire::settings::default_file_formats(); + let file_format; + // https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.collect_tuple + let _file_format = config.file_formats.iter().collect_tuple(); + if _file_format.is_none() { + log::debug!("CRITICAL::Failed to extract tuple from {:?}", config.file_formats); + file_format = default_values.iter().collect_tuple(); + } else { + file_format = _file_format + } + let args = (target_str, child_dir, file_format.unwrap()); let listing_page = squire::fileio::get_dir_stream_content(args); let listing = template.get_template("listing").unwrap(); return HttpResponse::build(StatusCode::OK)