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

View file

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

View file

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

View file

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

View file

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

View file

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