mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Properly increment installation attempts
This commit is contained in:
parent
43d28cc0c1
commit
64259e4a0b
1 changed files with 30 additions and 16 deletions
|
@ -210,10 +210,12 @@ fn start_default_prettier(
|
||||||
if let Err(e) = installation_task.await {
|
if let Err(e) = installation_task.await {
|
||||||
project.update(&mut cx, |project, _| {
|
project.update(&mut cx, |project, _| {
|
||||||
if let PrettierInstallation::NotInstalled {
|
if let PrettierInstallation::NotInstalled {
|
||||||
installation_task, ..
|
installation_task,
|
||||||
|
attempts,
|
||||||
} = &mut project.default_prettier.prettier
|
} = &mut project.default_prettier.prettier
|
||||||
{
|
{
|
||||||
*installation_task = None;
|
*installation_task = None;
|
||||||
|
*attempts += 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
|
@ -654,17 +656,9 @@ impl Project {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if installation_attempts > prettier::LAUNCH_THRESHOLD {
|
|
||||||
log::warn!(
|
|
||||||
"Default prettier installation has failed {installation_attempts} times, not attempting again",
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let fs = Arc::clone(&self.fs);
|
let fs = Arc::clone(&self.fs);
|
||||||
let new_installation_task = cx
|
let new_installation_task = cx
|
||||||
.spawn(|this, mut cx| async move {
|
.spawn(|project, mut cx| async move {
|
||||||
match locate_prettier_installation
|
match locate_prettier_installation
|
||||||
.await
|
.await
|
||||||
.context("locate prettier installation")
|
.context("locate prettier installation")
|
||||||
|
@ -677,6 +671,18 @@ impl Project {
|
||||||
match previous_installation_task.await {
|
match previous_installation_task.await {
|
||||||
Ok(()) => false,
|
Ok(()) => false,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
project.update(&mut cx, |project, _| {
|
||||||
|
if let PrettierInstallation::NotInstalled {
|
||||||
|
attempts,
|
||||||
|
..
|
||||||
|
} = &mut project.default_prettier.prettier
|
||||||
|
{
|
||||||
|
*attempts += 1;
|
||||||
|
installation_attempts = *attempts;
|
||||||
|
} else {
|
||||||
|
installation_attempts += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
log::error!("Failed to install default prettier: {e:#}");
|
log::error!("Failed to install default prettier: {e:#}");
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -684,9 +690,17 @@ impl Project {
|
||||||
}
|
}
|
||||||
None => true,
|
None => true,
|
||||||
};
|
};
|
||||||
this.update(&mut cx, |this, _| {
|
|
||||||
|
if installation_attempts > prettier::LAUNCH_THRESHOLD {
|
||||||
|
log::warn!(
|
||||||
|
"Default prettier installation has failed {installation_attempts} times, not attempting again",
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
project.update(&mut cx, |project, _| {
|
||||||
plugins_to_install.retain(|plugin| {
|
plugins_to_install.retain(|plugin| {
|
||||||
!this.default_prettier.installed_plugins.contains(plugin)
|
!project.default_prettier.installed_plugins.contains(plugin)
|
||||||
});
|
});
|
||||||
needs_install |= !plugins_to_install.is_empty();
|
needs_install |= !plugins_to_install.is_empty();
|
||||||
});
|
});
|
||||||
|
@ -700,13 +714,13 @@ impl Project {
|
||||||
.await
|
.await
|
||||||
.context("prettier & plugins install")
|
.context("prettier & plugins install")
|
||||||
.map_err(Arc::new)?;
|
.map_err(Arc::new)?;
|
||||||
this.update(&mut cx, |this, _| {
|
project.update(&mut cx, |project, _| {
|
||||||
this.default_prettier.prettier =
|
project.default_prettier.prettier =
|
||||||
PrettierInstallation::Installed(PrettierInstance {
|
PrettierInstallation::Installed(PrettierInstance {
|
||||||
attempt: 0,
|
attempt: 0,
|
||||||
prettier: None,
|
prettier: None,
|
||||||
});
|
});
|
||||||
this.default_prettier
|
project.default_prettier
|
||||||
.installed_plugins
|
.installed_plugins
|
||||||
.extend(installed_plugins);
|
.extend(installed_plugins);
|
||||||
});
|
});
|
||||||
|
@ -717,7 +731,7 @@ impl Project {
|
||||||
})
|
})
|
||||||
.shared();
|
.shared();
|
||||||
self.default_prettier.prettier = PrettierInstallation::NotInstalled {
|
self.default_prettier.prettier = PrettierInstallation::NotInstalled {
|
||||||
attempts: installation_attempts + 1,
|
attempts: installation_attempts,
|
||||||
installation_task: Some(new_installation_task),
|
installation_task: Some(new_installation_task),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue