Skip to content

Commit

Permalink
feat : 修改文件上传
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 committed Jun 15, 2022
1 parent d2924c5 commit 374b69a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
30 changes: 9 additions & 21 deletions pkg/util/podtool/copytopod.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"path"
"path/filepath"
"strings"
)

func (p *PodTool) CopyToContainer(destPath string) error {
Expand All @@ -26,18 +25,17 @@ func (p *PodTool) CopyToContainer(destPath string) error {
var stderr bytes.Buffer
p.ExecConfig.Stderr = &stderr
err := p.Exec(Exec)
var stdout bytes.Buffer
p.ExecConfig.Stdout = &stdout
if err != nil {
return fmt.Errorf(err.Error(), stderr)
}
if len(stderr.Bytes()) != 0 {
for _, line := range strings.Split(stderr.String(), "\n") {
if len(strings.TrimSpace(line)) == 0 {
continue
}
if !strings.Contains(strings.ToLower(line), "removing") {
return fmt.Errorf(line)
}
result := ""
if len(stdout.Bytes()) != 0 {
result = stdout.String()
}
if len(stderr.Bytes()) != 0 {
result = stderr.String()
}
return fmt.Errorf(err.Error(), result)
}
return nil
}
Expand Down Expand Up @@ -77,16 +75,6 @@ func (p *PodTool) CopyToPod(srcPath, destPath string) error {
}
return fmt.Errorf(err.Error(), result)
}
if len(stderr.Bytes()) != 0 {
for _, line := range strings.Split(stderr.String(), "\n") {
if len(strings.TrimSpace(line)) == 0 {
continue
}
if !strings.Contains(strings.ToLower(line), "removing") {
return fmt.Errorf(line)
}
}
}
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<div slot="tip" class="el-upload__tip">{{ $t("business.pod.upload_tip") }}</div>
</el-upload>
<span slot="footer" class="dialog-footer">
<el-button @click="openUpload=false" :disabled="loading">{{ $t("commons.button.cancel") }}</el-button>
<el-button @click="handleUploadClose" :disabled="loading">{{ $t("commons.button.cancel") }}</el-button>
<el-button type="primary" @click="upload" :loading="loading">{{ $t("commons.button.confirm") }}</el-button>
</span>
</el-dialog>
Expand Down

0 comments on commit 374b69a

Please sign in to comment.