mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Fix path parsing for add command
License: MIT Signed-off-by: Dominic Della Valle <ddvpublic@gmail.com>
This commit is contained in:
parent
fb8189d601
commit
a6eb32b77c
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user