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.
|
||||
/// 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> {
|
||||
let mut compose_args = vec!["compose"];
|
||||
compose_args.extend_from_slice(args);
|
||||
@@ -104,14 +104,32 @@ pub fn run_compose_command(dir: &Path, args: &[&str]) -> std::io::Result<Output>
|
||||
.output();
|
||||
|
||||
match output {
|
||||
Ok(out) if out.status.success() => Ok(out),
|
||||
_ => {
|
||||
// Fallback auf docker-compose (v1)
|
||||
Ok(out) => {
|
||||
let stderr = String::from_utf8_lossy(&out.stderr);
|
||||
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")
|
||||
.current_dir(dir)
|
||||
.args(args)
|
||||
.output()
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user