resolve crash when there a directory
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2023-05-02 13:07:04 +02:00
parent 49392f5ca5
commit 36d4889983
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -99,7 +99,10 @@ fn get_posts(location: &str) -> Vec<Post> {
let entries = match std::fs::read_dir(location) { let entries = match std::fs::read_dir(location) {
Ok(res) => res Ok(res) => res
.flatten() .flatten()
.filter(|f| f.path().extension().unwrap() == "md") .filter(|f| match f.path().extension() {
Some(ext) => ext == "md",
None => false,
})
.collect::<Vec<std::fs::DirEntry>>(), .collect::<Vec<std::fs::DirEntry>>(),
Err(_) => vec![], Err(_) => vec![],
}; };