fix logic in src/feed crashing when a feed entry doesn't have the required attributes
instead the entry just isn't included, as it always should've been.
This commit is contained in:
parent
73cd7efcf7
commit
9938bba666
1 changed files with 28 additions and 28 deletions
56
src/feed.rs
56
src/feed.rs
|
@ -16,34 +16,34 @@ pub fn generate(sources: &Sources, tag_name: &str) -> Option<Vec<FeedEntry>> {
|
||||||
|
|
||||||
let tag = sources.treehouse.tags.get(tag_name)?;
|
let tag = sources.treehouse.tags.get(tag_name)?;
|
||||||
for file_id in &tag.files {
|
for file_id in &tag.files {
|
||||||
if let Some(roots) = sources.treehouse.roots.get(file_id)
|
if let Some(roots) = sources.treehouse.roots.get(file_id) {
|
||||||
&& let Some(id) = roots.attributes.id.clone()
|
if let Some(id) = roots.attributes.id.clone() {
|
||||||
{
|
entries.push(FeedEntry {
|
||||||
entries.push(FeedEntry {
|
id,
|
||||||
id,
|
updated: roots.attributes.timestamps.map(|ts| ts.updated),
|
||||||
updated: roots.attributes.timestamps.map(|ts| ts.updated),
|
url: format!(
|
||||||
url: format!(
|
"{}/{}.tree",
|
||||||
"{}/{}.tree",
|
sources.config.site,
|
||||||
sources.config.site,
|
sources.treehouse.tree_path(*file_id).unwrap()
|
||||||
sources.treehouse.tree_path(*file_id).unwrap()
|
),
|
||||||
),
|
title: roots.attributes.title.clone(),
|
||||||
title: roots.attributes.title.clone(),
|
tags: roots.attributes.tags.clone(),
|
||||||
tags: roots.attributes.tags.clone(),
|
});
|
||||||
});
|
}
|
||||||
} else if let Some(doc) = sources.treehouse.docs.get(file_id)
|
} else if let Some(doc) = sources.treehouse.docs.get(file_id) {
|
||||||
&& !doc.attributes.id.is_empty()
|
if !doc.attributes.id.is_empty() && doc.attributes.updated.is_some() {
|
||||||
{
|
entries.push(FeedEntry {
|
||||||
entries.push(FeedEntry {
|
id: doc.attributes.id.clone(),
|
||||||
id: doc.attributes.id.clone(),
|
updated: doc.attributes.updated,
|
||||||
updated: doc.attributes.updated,
|
url: format!(
|
||||||
url: format!(
|
"{}/{}",
|
||||||
"{}/{}",
|
sources.config.site,
|
||||||
sources.config.site,
|
sources.treehouse.path(*file_id).with_extension("")
|
||||||
sources.treehouse.path(*file_id).with_extension("")
|
),
|
||||||
),
|
title: doc.attributes.title.clone(),
|
||||||
title: doc.attributes.title.clone(),
|
tags: doc.attributes.tags.clone(),
|
||||||
tags: doc.attributes.tags.clone(),
|
});
|
||||||
});
|
}
|
||||||
} else {
|
} else {
|
||||||
unreachable!(
|
unreachable!(
|
||||||
"{file_id:?} registered in tag #{tag_name} is not actually in the treehouse"
|
"{file_id:?} registered in tag #{tag_name} is not actually in the treehouse"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue