提交 a6eb32b7 作者: Dominic Della Valle

Fix path parsing for add command

License: MIT
Signed-off-by: 's avatarDominic Della Valle <ddvpublic@gmail.com>
上级 fb8189d6
......@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path"
"path/filepath"
"runtime"
"strings"
......@@ -364,7 +365,7 @@ func appendStdinAsString(args []string, stdin *os.File) ([]string, *os.File, err
}
func appendFile(args []files.File, inputs []string, argDef *cmds.Argument, recursive bool) ([]files.File, []string, error) {
fpath := inputs[0]
fpath := filepath.ToSlash(filepath.Clean(inputs[0]))
if fpath == "." {
cwd, err := os.Getwd()
......
......@@ -5,7 +5,7 @@ import (
"io"
"io/ioutil"
"os"
fp "path/filepath"
"path/filepath"
"syscall"
)
......@@ -69,8 +69,8 @@ func (f *serialFile) NextFile() (File, error) {
f.files = f.files[1:]
// open the next file
fileName := fp.Join(f.name, stat.Name())
filePath := fp.Join(f.path, stat.Name())
fileName := filepath.ToSlash(filepath.Join(f.name, stat.Name()))
filePath := filepath.ToSlash(filepath.Join(f.path, stat.Name()))
// recursively call the constructor on the next file
// if it's a regular file, we will open it as a ReaderFile
......@@ -120,7 +120,7 @@ func (f *serialFile) Size() (int64, error) {
}
var du int64
err := fp.Walk(f.FileName(), func(p string, fi os.FileInfo, err error) error {
err := filepath.Walk(f.FileName(), func(p string, fi os.FileInfo, err error) error {
if fi != nil && fi.Mode()&(os.ModeSymlink|os.ModeNamedPipe) == 0 {
du += fi.Size()
}
......
......@@ -446,7 +446,7 @@ func (params *adder) addDir(file files.File) (*dag.Node, error) {
}
if node != nil {
_, name := path.Split(file.FileName())
name := path.Base(file.FileName())
err = tree.AddNodeLink(name, node)
if err != nil {
......
......@@ -174,7 +174,7 @@ func (i *gatewayHandler) getOrHeadHandler(w http.ResponseWriter, r *http.Request
if err == nil {
defer dr.Close()
_, name := gopath.Split(urlPath)
name := gopath.Base(urlPath)
http.ServeContent(w, r, name, modtime, dr)
return
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论