1
Fork 0

Lowercase video directory names and check total count.

Netlify makes paths case-insensitive after deploying so lowercase
the video IDs and then add a check for total count so there isn't
a collision.
This commit is contained in:
Bauke 2023-01-10 16:17:19 +01:00
parent fa7c98e079
commit 46bf389dc3
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,10 @@
use std::{fs, path::Path};
use {askama::Template, color_eyre::Result, serde::Deserialize};
use {
askama::Template,
color_eyre::{eyre::eyre, Result},
serde::Deserialize,
};
mod filters;
@ -55,8 +59,11 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
data
};
let video_dir = public_dir.join("v");
let expected_video_count = video_datas.len();
for (video_data, markdown) in video_datas {
let video_dir = public_dir.join("v").join(&video_data.id);
let video_dir = video_dir.join(&video_data.id.to_lowercase());
fs::create_dir_all(&video_dir)?;
let template = VideoTemplate {
@ -75,5 +82,14 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
)?;
}
let actual_video_count = fs::read_dir(video_dir)?.count();
if expected_video_count != actual_video_count {
return Err(eyre!(
"Expected {} videos, found {}",
expected_video_count,
actual_video_count
));
}
Ok(())
}