Fix: Fallback auf docker-compose bei Nichtverfügbarkeit in updater.rs
This commit is contained in:
+22
-4
@@ -93,7 +93,7 @@ fn run_docker_command(args: &[&str]) -> std::io::Result<Output> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Führt einen Docker-Compose-Befehl im angegebenen Verzeichnis aus.
|
/// Führt einen Docker-Compose-Befehl im angegebenen Verzeichnis aus.
|
||||||
/// Versucht zuerst `docker compose` und fällt bei Bedarf auf `docker-compose` zurück.
|
/// Versucht zuerst `docker compose` und fällt bei Nichtverfügbarkeit auf `docker-compose` zurück.
|
||||||
pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output> {
|
pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output> {
|
||||||
let mut compose_args = vec!["compose"];
|
let mut compose_args = vec!["compose"];
|
||||||
compose_args.extend_from_slice(args);
|
compose_args.extend_from_slice(args);
|
||||||
@@ -104,14 +104,32 @@ pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output>
|
|||||||
.output();
|
.output();
|
||||||
|
|
||||||
match output {
|
match output {
|
||||||
Ok(out) if out.status.success() => Ok(out),
|
Ok(out) => {
|
||||||
_ => {
|
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||||
// Fallback auf docker-compose (v1)
|
let is_unavailable = !out.status.success()
|
||||||
|
&& (stderr.contains("is not a docker command")
|
||||||
|
|| stderr.contains("unknown command \"compose\"")
|
||||||
|
|| stderr.contains("unknown command: compose"));
|
||||||
|
|
||||||
|
if is_unavailable {
|
||||||
|
if let Ok(fallback_out) = Command::new("docker-compose")
|
||||||
|
.current_dir(dir)
|
||||||
|
.args(args)
|
||||||
|
.output()
|
||||||
|
{
|
||||||
|
return Ok(fallback_out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
|
||||||
|
// docker-Binary nicht gefunden, versuche docker-compose
|
||||||
Command::new("docker-compose")
|
Command::new("docker-compose")
|
||||||
.current_dir(dir)
|
.current_dir(dir)
|
||||||
.args(args)
|
.args(args)
|
||||||
.output()
|
.output()
|
||||||
}
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user