From 3bc537df95f4aa49a0bade6ee77a379e9bdaa4f1 Mon Sep 17 00:00:00 2001 From: jim800121chen Date: Mon, 9 Mar 2026 18:15:21 +0800 Subject: [PATCH] fix: abort installation on critical step failure Previously all step errors were treated as warnings and installation continued silently. Now critical steps (create dir, extract binary, extract data/scripts, write config) will abort with an error message. Non-critical steps (libusb, python venv, symlink, auto-start) still warn and skip. Co-Authored-By: Claude Opus 4.6 --- edge-ai-platform/installer/app.go | 39 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/edge-ai-platform/installer/app.go b/edge-ai-platform/installer/app.go index 385dee2..d122dc5 100644 --- a/edge-ai-platform/installer/app.go +++ b/edge-ai-platform/installer/app.go @@ -200,20 +200,21 @@ func (inst *Installer) StartInstall(config InstallConfig) error { func (inst *Installer) runInstall(config InstallConfig) { steps := []struct { - name string - percent float64 - fn func(config InstallConfig) error + name string + percent float64 + critical bool // if true, abort installation on failure + fn func(config InstallConfig) error }{ - {"Creating installation directory", 5, inst.stepCreateDir}, - {"Extracting server binary", 10, inst.stepExtractBinary}, - {"Extracting models and firmware", 30, inst.stepExtractData}, - {"Extracting scripts", 48, inst.stepExtractScripts}, - {"Configuring system", 55, inst.stepConfigureSystem}, - {"Setting up USB driver", 62, inst.stepSetupLibusb}, - {"Setting up Python environment", 72, inst.stepSetupPython}, - {"Writing configuration", 85, inst.stepWriteConfig}, - {"Verifying installation", 90, inst.stepVerify}, - {"Setting up auto-start launcher", 95, inst.stepAutoRestart}, + {"Creating installation directory", 5, true, inst.stepCreateDir}, + {"Extracting server binary", 10, true, inst.stepExtractBinary}, + {"Extracting models and firmware", 30, true, inst.stepExtractData}, + {"Extracting scripts", 48, true, inst.stepExtractScripts}, + {"Configuring system", 55, false, inst.stepConfigureSystem}, + {"Setting up USB driver", 62, false, inst.stepSetupLibusb}, + {"Setting up Python environment", 72, false, inst.stepSetupPython}, + {"Writing configuration", 85, true, inst.stepWriteConfig}, + {"Verifying installation", 90, false, inst.stepVerify}, + {"Setting up auto-start launcher", 95, false, inst.stepAutoRestart}, } for _, step := range steps { @@ -224,13 +225,21 @@ func (inst *Installer) runInstall(config InstallConfig) { }) if err := step.fn(config); err != nil { + if step.critical { + inst.emitProgress(ProgressEvent{ + Step: step.name, + Message: fmt.Sprintf("Error: %s — %s", step.name, err), + Percent: step.percent, + IsError: true, + }) + return // abort installation + } inst.emitProgress(ProgressEvent{ Step: step.name, - Message: fmt.Sprintf("Warning: %s — %s", step.name, err), + Message: fmt.Sprintf("Warning: %s — %s (skipped)", step.name, err), Percent: step.percent, IsError: true, }) - // Non-critical steps continue; critical ones are handled inside } }