mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-07 17:10:07 +08:00
fix: 解决文件复制粘贴路径中带空格导致失败的问题 (#2883)
Refs https://github.com/1Panel-dev/1Panel/issues/2877
This commit is contained in:
parent
8660ac6fe5
commit
88ad8b1b71
@ -299,7 +299,8 @@ func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error {
|
|||||||
if cover {
|
if cover {
|
||||||
coverFlag = "-f"
|
coverFlag = "-f"
|
||||||
}
|
}
|
||||||
cmdStr := fmt.Sprintf("mv %s %s %s", coverFlag, p, dstPath)
|
|
||||||
|
cmdStr := fmt.Sprintf(`mv %s "%s" "%s"`, coverFlag, p, dstPath)
|
||||||
if err := cmd.ExecCmd(cmdStr); err != nil {
|
if err := cmd.ExecCmd(cmdStr); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -362,13 +363,13 @@ func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error {
|
|||||||
if name != "" && !cover {
|
if name != "" && !cover {
|
||||||
dstPath = filepath.Join(dst, name)
|
dstPath = filepath.Join(dst, name)
|
||||||
}
|
}
|
||||||
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dstPath))
|
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dstPath))
|
||||||
} else {
|
} else {
|
||||||
dstPath := filepath.Join(dst, name)
|
dstPath := filepath.Join(dst, name)
|
||||||
if cover {
|
if cover {
|
||||||
dstPath = dst
|
dstPath = dst
|
||||||
}
|
}
|
||||||
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dstPath))
|
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dstPath))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,11 +382,12 @@ func (f FileOp) CopyDir(src, dst string) error {
|
|||||||
if err = f.Fs.MkdirAll(dstDir, srcInfo.Mode()); err != nil {
|
if err = f.Fs.MkdirAll(dstDir, srcInfo.Mode()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return cmd.ExecCmd(fmt.Sprintf("cp -rf %s %s", src, dst+"/"))
|
return cmd.ExecCmd(fmt.Sprintf(`cp -rf "%s" "%s"`, src, dst+"/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileOp) CopyFile(src, dst string) error {
|
func (f FileOp) CopyFile(src, dst string) error {
|
||||||
return cmd.ExecCmd(fmt.Sprintf("cp -f %s %s", src, dst+"/"))
|
dst = filepath.Clean(dst) + string(filepath.Separator)
|
||||||
|
return cmd.ExecCmd(fmt.Sprintf(`cp -f "%s" "%s"`, src, dst+"/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f FileOp) GetDirSize(path string) (float64, error) {
|
func (f FileOp) GetDirSize(path string) (float64, error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user