[F] Fix cache path might be missing
This commit is contained in:
@@ -118,8 +118,6 @@ fn main() -> Result<()> {
|
|||||||
.context("failed to write message to stdout")?;
|
.context("failed to write message to stdout")?;
|
||||||
|
|
||||||
if !june_path.is_file() {
|
if !june_path.is_file() {
|
||||||
fs::create_dir_all(&cache_path)
|
|
||||||
.with_context(|| format!("failed to create cache dir {cache_path:?}"))?;
|
|
||||||
File::create(&june_path)
|
File::create(&june_path)
|
||||||
.with_context(|| format!("failed to create file {june_path:?}"))?;
|
.with_context(|| format!("failed to create file {june_path:?}"))?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,11 +34,6 @@ pub fn get_font_logo(backend: Backend) -> Result<String> {
|
|||||||
|
|
||||||
let logo = font_logos.get(matched_distro).unwrap();
|
let logo = font_logos.get(matched_distro).unwrap();
|
||||||
|
|
||||||
// Create parent directories for the cache if they don't exist
|
|
||||||
if let Some(parent) = cache_path.parent() {
|
|
||||||
fs::create_dir_all(parent).context("Failed to create cache directory")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the logo to the cache file
|
// Write the logo to the cache file
|
||||||
let mut cache_file = File::create(cache_path).context("Failed to create cache file")?;
|
let mut cache_file = File::create(cache_path).context("Failed to create cache file")?;
|
||||||
cache_file.write_all(logo.as_bytes()).context("Failed to write logo to cache file")?;
|
cache_file.write_all(logo.as_bytes()).context("Failed to write logo to cache file")?;
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ pub fn get_cache_path() -> Result<PathBuf> {
|
|||||||
.context("failed to get base dirs")?
|
.context("failed to get base dirs")?
|
||||||
.cache_dir()
|
.cache_dir()
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
|
// Make sure the cache directory exists
|
||||||
|
if !path.exists() {
|
||||||
|
fs::create_dir_all(&path).with_context(|| format!("failed to create cache dir {path:?}"))?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(path)
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user