From e5b2b5d5dca6294293e8fb77b3e11509d8ff1110 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Sat, 9 May 2026 18:08:00 +0800 Subject: [PATCH] fix: pass context to rar extraction and simplify sidebar message entry (#12697) --- agent/utils/cmd/cmd_test.go | 23 ------------------- agent/utils/files/rar.go | 2 +- .../Sidebar/components/Collapse.vue | 6 ++--- 3 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 agent/utils/cmd/cmd_test.go diff --git a/agent/utils/cmd/cmd_test.go b/agent/utils/cmd/cmd_test.go deleted file mode 100644 index d2c622af5..000000000 --- a/agent/utils/cmd/cmd_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package cmd - -import "testing" - -// TestWhich_ExistingBinary verifies that Which() returns true for a -// binary that is guaranteed to exist on every Unix-like build host -// (`sh`). Regression test for #12605: the previous implementation -// shelled out to `which`, which is not always available on minimal -// distributions like Arch Linux. The new implementation tries -// exec.LookPath first, so this assertion holds regardless of whether -// `which` itself is on PATH. -func TestWhich_ExistingBinary(t *testing.T) { - if !Which("sh") { - t.Errorf("Which(\"sh\") = false, want true") - } -} - -func TestWhich_MissingBinary(t *testing.T) { - // A binary name that is extremely unlikely to exist on any host. - if Which("definitely-not-a-real-binary-xyzzy-1panel") { - t.Errorf("Which(\"definitely-not-a-real-binary-xyzzy-1panel\") = true, want false") - } -} diff --git a/agent/utils/files/rar.go b/agent/utils/files/rar.go index 03c7c2b37..2fdaf312d 100644 --- a/agent/utils/files/rar.go +++ b/agent/utils/files/rar.go @@ -23,7 +23,7 @@ func (z RarArchiver) Extract(ctx context.Context, filePath, dstDir string, _ str if err := checkCmdAvailability("unrar"); err != nil { return err } - return cmd.NewCommandMgr().Run("unrar", "x", "-y", "-o+", filePath, dstDir) + return cmd.NewCommandMgr(cmd.WithContext(ctx)).Run("unrar", "x", "-y", "-o+", filePath, dstDir) } func (z RarArchiver) Compress(ctx context.Context, sourcePaths []string, dstFile string, _ string) (err error) { diff --git a/frontend/src/layout/components/Sidebar/components/Collapse.vue b/frontend/src/layout/components/Sidebar/components/Collapse.vue index 593eba030..d30a81dc1 100644 --- a/frontend/src/layout/components/Sidebar/components/Collapse.vue +++ b/frontend/src/layout/components/Sidebar/components/Collapse.vue @@ -32,10 +32,8 @@