mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/1Panel-dev/1Panel.git
synced 2026-09-20 08:03:55 +08:00
fix: fix ClamAV scan failure issue (#12892)
This commit is contained in:
@@ -219,7 +219,7 @@ func (c *CommandHelper) pipeContext() (context.Context, context.CancelFunc) {
|
||||
func (c *CommandHelper) buildPipeCommands(ctx context.Context, commands []PipeCommand) []*exec.Cmd {
|
||||
cmds := make([]*exec.Cmd, 0, len(commands))
|
||||
for _, item := range commands {
|
||||
cmdItem := exec.CommandContext(ctx, item.Name, item.Args...)
|
||||
cmdItem := exec.CommandContext(ctx, item.Name, filterEmptyArgs(item.Args)...)
|
||||
cmdItem.Env = append(os.Environ(), c.env...)
|
||||
cmdItem.Env = append(cmdItem.Env, item.Env...)
|
||||
cmdItem.Dir = c.workDir
|
||||
@@ -284,6 +284,7 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
|
||||
var newContext context.Context
|
||||
var cancel context.CancelFunc
|
||||
var outputFile *os.File
|
||||
arg = filterEmptyArgs(arg)
|
||||
|
||||
if c.timeout != 0 {
|
||||
if c.context == nil {
|
||||
@@ -378,6 +379,20 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func filterEmptyArgs(args []string) []string {
|
||||
if len(args) == 0 {
|
||||
return args
|
||||
}
|
||||
filtered := args[:0]
|
||||
for _, arg := range args {
|
||||
if arg == "" {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, arg)
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
func contextDone(ctx context.Context) <-chan struct{} {
|
||||
if ctx == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user