1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-04-26 00:37:44 +00:00

Don't crash if no patch files are provided

This commit is contained in:
Joshua Goins 2025-03-08 13:24:14 -05:00
parent 5dc1178cd3
commit f7a5940f20

View file

@ -15,7 +15,11 @@ use minijinja::filters::list;
use kawari::patchlist::{PatchEntry, PatchList, PatchType};
fn list_patch_files(dir_path: &str) -> Vec<String> {
let mut entries: Vec<_> = read_dir(dir_path).unwrap().flatten().collect();
// If the dir doesn't exist, pretend there is no patch files
let Ok(dir) = read_dir(dir_path) else {
return Vec::new()
};
let mut entries: Vec<_> = dir.flatten().collect();
entries.sort_by_key(|dir| dir.path());
let mut game_patches: Vec<_> = entries
.into_iter()
@ -117,4 +121,4 @@ async fn main() {
.serve(app.into_make_service())
.await
.unwrap();
}
}