fix clippy lints and improve error handling
This commit is contained in:
parent
aeaa6eb3a6
commit
dd0ad8d538
5 changed files with 21 additions and 6 deletions
|
@ -6,6 +6,10 @@
|
|||
|
||||
# Run RSS debug tool
|
||||
cargo run -- debug-rss untracked/*.rss
|
||||
|
||||
# Debug the HTML output
|
||||
# (You may need to run 'auto' mode first to download the ICS files)
|
||||
cargo run -- debug-output --config config.toml
|
||||
```
|
||||
|
||||
# TODO
|
||||
|
|
|
@ -348,6 +348,15 @@ fn output_html(
|
|||
}
|
||||
|
||||
std::fs::create_dir_all("output")?;
|
||||
{
|
||||
let temp_path = "output/calendars.html.tmp";
|
||||
let final_path = "output/calendars.html";
|
||||
let mut f = std::fs::File::create(temp_path)?;
|
||||
|
||||
f.write_all("".as_bytes())?;
|
||||
std::fs::rename(temp_path, final_path)?;
|
||||
}
|
||||
|
||||
{
|
||||
let temp_path = "output/index.html.tmp";
|
||||
let final_path = "output/index.html";
|
||||
|
|
|
@ -110,7 +110,8 @@ impl Calendar {
|
|||
}
|
||||
|
||||
pub(crate) fn read_from_config(config: Config) -> Result<Self> {
|
||||
let s = std::fs::read_to_string(&config.dl.file_path)?;
|
||||
let path = &config.dl.file_path;
|
||||
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?;
|
||||
Self::read_from_str(config, &s)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,8 @@ impl Calendar {
|
|||
}
|
||||
|
||||
pub(crate) fn read_from_config(config: Config) -> Result<Self> {
|
||||
let s = std::fs::read_to_string(&config.dl.file_path)?;
|
||||
let path = &config.dl.file_path;
|
||||
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?;
|
||||
Self::read_from_str(config, &s)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ fn ical_event_instances(
|
|||
vec![dtstart_normalized]
|
||||
};
|
||||
|
||||
let instances = dates
|
||||
dates
|
||||
.into_iter()
|
||||
.map(|dtstart| {
|
||||
let has_rrule = ev.properties().get("RRULE").is_some();
|
||||
|
@ -179,8 +179,7 @@ fn ical_event_instances(
|
|||
url,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
instances
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Used to link recurrence exceptions to the original events they replace
|
||||
|
@ -268,7 +267,8 @@ impl Calendar {
|
|||
}
|
||||
|
||||
pub(crate) fn read_from_config(config: Config) -> Result<Self> {
|
||||
let s = std::fs::read_to_string(&config.dl.file_path)?;
|
||||
let path = &config.dl.file_path;
|
||||
let s = std::fs::read_to_string(path).with_context(|| format!("Couldn't read {path:?}"))?;
|
||||
Self::read_from_str(config, &s)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue