Avoid logging errors about missing themes dir (#7290)
This commit is contained in:
parent
115f0672fb
commit
2d58226a9b
1 changed files with 25 additions and 15 deletions
|
@ -892,27 +892,37 @@ fn load_user_themes_in_background(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||||
if let Some(theme_registry) =
|
if let Some(theme_registry) =
|
||||||
cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
|
cx.update(|cx| ThemeRegistry::global(cx).clone()).log_err()
|
||||||
{
|
{
|
||||||
if let Some(()) = theme_registry
|
let themes_dir = paths::THEMES_DIR.as_ref();
|
||||||
.load_user_themes(&paths::THEMES_DIR.clone(), fs)
|
match fs
|
||||||
|
.metadata(themes_dir)
|
||||||
.await
|
.await
|
||||||
.log_err()
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.map(|m| m.is_dir)
|
||||||
{
|
{
|
||||||
|
Some(is_dir) => {
|
||||||
|
anyhow::ensure!(is_dir, "Themes dir path {themes_dir:?} is not a directory")
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
fs.create_dir(themes_dir).await.with_context(|| {
|
||||||
|
format!("Failed to create themes dir at path {themes_dir:?}")
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theme_registry.load_user_themes(themes_dir, fs).await?;
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
let mut theme_settings = ThemeSettings::get_global(cx).clone();
|
let mut theme_settings = ThemeSettings::get_global(cx).clone();
|
||||||
|
|
||||||
if let Some(requested_theme) = theme_settings.requested_theme.clone() {
|
if let Some(requested_theme) = theme_settings.requested_theme.clone() {
|
||||||
if let Some(_theme) = theme_settings.switch_theme(&requested_theme, cx)
|
if let Some(_theme) = theme_settings.switch_theme(&requested_theme, cx) {
|
||||||
{
|
|
||||||
ThemeSettings::override_global(theme_settings, cx);
|
ThemeSettings::override_global(theme_settings, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})?;
|
||||||
.log_err();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawns a background task to watch the themes directory for changes.
|
/// Spawns a background task to watch the themes directory for changes.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue