1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-10-01 16:54:08 +02:00

clippy fixes

This commit is contained in:
Robin Appelman 2026-08-17 19:04:46 +02:00
commit b1b4ac3ce9
6 changed files with 15 additions and 23 deletions

View file

@ -711,15 +711,14 @@ impl Cloud {
.await
.into_diagnostic()
.wrap_err("Failed to remove network")?;
if self.workdir.exists() {
if let Err(e) = remove_dir_all(self.workdir)
if self.workdir.exists()
&& let Err(e) = remove_dir_all(self.workdir)
.await
.into_diagnostic()
.wrap_err("Failed to remove work directory")
{
eprintln!("{}", e);
}
}
remove_worktrees_for_instance(config, &self.id).await?;
@ -804,8 +803,8 @@ impl Cloud {
let mut containers_by_id: HashMap<String, (Option<_>, Vec<_>)> = HashMap::new();
for container in containers {
let labels = container.labels.clone().unwrap_or_default();
if let Some(cloud_id) = labels.get("haze-cloud-id") {
if match filter.as_ref() {
if let Some(cloud_id) = labels.get("haze-cloud-id")
&& match filter.as_ref() {
Some(filter) => cloud_id.contains(filter),
None => true,
} {
@ -816,7 +815,6 @@ impl Cloud {
entry.1.push(container)
}
}
}
}
let mut sortable_containers: Vec<_> = containers_by_id

View file

@ -92,8 +92,7 @@ async fn main() -> Result<ExitCode> {
let cache_dir = cache_dir.into_diagnostic()?;
if let Some(id) = cache_dir.file_name().to_str()
&& id.starts_with("haze-")
{
if !retain.iter().any(|cloud| cloud.id == id) {
&& !retain.iter().any(|cloud| cloud.id == id) {
let path = cache_dir.path();
// By default, the worktrees live within the work dir, we do not want to delete it here.
if path == config.worktree_dir {
@ -110,7 +109,6 @@ async fn main() -> Result<ExitCode> {
})?;
}
}
}
}
prune_worktrees(&config)?;

View file

@ -10,13 +10,11 @@ pub async fn clear_networks(docker: &Docker, instances: &[Cloud]) -> Result<()>
.into_diagnostic()
.wrap_err("Failed to list docker networks")?;
for network in networks {
if let Some(name) = network.name.as_deref() {
if let Some(id) = name.strip_prefix("haze-") {
if !instances.iter().any(|cloud| cloud.id == id) {
if let Some(name) = network.name.as_deref()
&& let Some(id) = name.strip_prefix("haze-")
&& !instances.iter().any(|cloud| cloud.id == id) {
docker.remove_network(name).await.ok();
}
}
}
}
Ok(())
}

View file

@ -126,8 +126,8 @@ impl PhpVersion {
let image_version = image_version(docker, self.image()).await;
let haze_version = ImageVersion::from_str(env!("CARGO_PKG_VERSION"));
if let (Some(image_version), Ok(haze_version)) = (image_version, haze_version) {
if image_version < haze_version {
if let (Some(image_version), Ok(haze_version)) = (image_version, haze_version)
&& image_version < haze_version {
eprintln!(
"{}: image version is out of date, run {} to update.",
"Warning".red(),
@ -136,7 +136,6 @@ impl PhpVersion {
eprintln!(" Haze version: {}", haze_version.bright_yellow());
eprintln!(" Image version: {}", image_version.bright_yellow());
}
}
let options = Some(CreateContainerOptions {
name: Some(id.to_string()),

View file

@ -201,12 +201,11 @@ async fn serve(instances: ActiveInstances, listen: String, base_address: String)
}
} else {
let listen: PathBuf = listen.into();
if let Some(parent) = listen.parent() {
if !parent.exists() {
if let Some(parent) = listen.parent()
&& !parent.exists() {
create_dir_all(parent).into_diagnostic()?;
set_permissions(parent, PermissionsExt::from_mode(0o755)).into_diagnostic()?;
}
}
let _ = tokio::fs::remove_file(&listen).await;
let listener = UnixListener::bind(&listen).unwrap();

View file

@ -57,10 +57,10 @@ pub async fn run_script(
.dont_create(),
);
let cloud = setup(docker, options, &config).await?;
let cloud = setup(docker, options, config).await?;
cloud
.exec(
&docker,
docker,
vec![shell.to_string(), target_path.into_string()],
true,
get_forward_env(),
@ -68,7 +68,7 @@ pub async fn run_script(
.await?;
if mode == ScriptMode::Shell {
cloud.destroy(&docker, &config).await?;
cloud.destroy(docker, config).await?;
}
Ok(())