aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_fs_du.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-04-03 00:20:00 -0700
committerChris Lu <chris.lu@gmail.com>2019-04-03 00:20:00 -0700
commit715a38da1e4fce05631f230ccf09ce92c99a4fd4 (patch)
treedc443bbe30b2178f24c67c19ef732013b8cabd0f /weed/shell/command_fs_du.go
parent20dcb44077bcb8164b8351ee506af8385e8fd6ef (diff)
downloadseaweedfs-715a38da1e4fce05631f230ccf09ce92c99a4fd4.tar.xz
seaweedfs-715a38da1e4fce05631f230ccf09ce92c99a4fd4.zip
weed shell: add fs.cd, fs.pwd to change to a directory and print current directory
Diffstat (limited to 'weed/shell/command_fs_du.go')
-rw-r--r--weed/shell/command_fs_du.go25
1 files changed, 2 insertions, 23 deletions
diff --git a/weed/shell/command_fs_du.go b/weed/shell/command_fs_du.go
index 3fecac9a8..98e2eebd1 100644
--- a/weed/shell/command_fs_du.go
+++ b/weed/shell/command_fs_du.go
@@ -8,8 +8,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
"google.golang.org/grpc"
"io"
- "net/url"
- "strconv"
"strings"
)
@@ -35,7 +33,7 @@ func (c *commandFsDu) Help() string {
func (c *commandFsDu) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
- filerServer, filerPort, path, err := parseFilerUrl(args[0])
+ filerServer, filerPort, path, err := commandEnv.parseUrl(args[0])
if err != nil {
return err
}
@@ -45,7 +43,7 @@ func (c *commandFsDu) Do(args []string, commandEnv *commandEnv, writer io.Writer
if path == "/" {
dir, name = "/", ""
} else {
- dir, name = path[0:len(path)-1], ""
+ dir, name = path[0 : len(path)-1], ""
}
}
@@ -112,25 +110,6 @@ func paginateDirectory(ctx context.Context, writer io.Writer, client filer_pb.Se
}
-func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
- if strings.HasPrefix(entryPath, "http") {
- var u *url.URL
- u, err = url.Parse(entryPath)
- if err != nil {
- return
- }
- filerServer = u.Hostname()
- portString := u.Port()
- if portString != "" {
- filerPort, err = strconv.ParseInt(portString, 10, 32)
- }
- path = u.Path
- } else {
- err = fmt.Errorf("path should have full url http://<filer_server>:<port>/path/to/dirOrFile : %s", entryPath)
- }
- return
-}
-
func (env *commandEnv) withFilerClient(ctx context.Context, filerServer string, filerPort int64, fn func(filer_pb.SeaweedFilerClient) error) error {
filerGrpcAddress := fmt.Sprintf("%s:%d", filerServer, filerPort+10000)