get rid of an unwrap
All checks were successful
CI/CD Pipeline / test (push) Successful in 5m18s

This commit is contained in:
philipp 2024-02-27 12:24:27 +01:00
parent 4eac917f2a
commit 836f8934d0

View File

@ -70,7 +70,8 @@ impl From<roxmltree::Error> for Error {
/// Returns the current date in YYYY-MM-DD format. Needed for RIS API query to get current version of the overview. /// Returns the current date in YYYY-MM-DD format. Needed for RIS API query to get current version of the overview.
pub(crate) fn current_date() -> String { pub(crate) fn current_date() -> String {
let local_date = OffsetDateTime::now_utc(); let local_date = OffsetDateTime::now_utc();
let format = format_description::parse("[year]-[month]-[day]").unwrap(); //unwrap okay, supplied format is fine let format = format_description::parse("[year]-[month]-[day]")
.expect("Can't fail, supplied format is fine");
local_date.format(&format).expect("Failed to format date") local_date.format(&format).expect("Failed to format date")
} }
@ -80,7 +81,12 @@ pub(crate) fn get_cache_dir() -> Result<String, Error> {
msg: "directories crate could not find basedirs.".into(), msg: "directories crate could not find basedirs.".into(),
})?; })?;
let cache_dir = cache_dir.cache_dir(); let cache_dir = cache_dir.cache_dir();
Ok(format!("{}/risp/", cache_dir.to_str().unwrap())) Ok(format!(
"{}/risp/",
cache_dir
.to_str()
.ok_or(Error::new("Cache dir can't be found"))?
))
} }
#[cfg(test)] #[cfg(test)]