diff --git a/cmd-session.go b/cmd-session.go index 17173d7d..ccedda54 100644 --- a/cmd-session.go +++ b/cmd-session.go @@ -30,13 +30,13 @@ import ( // Help message. var sessionCmd = cli.Command{ Name: "session", - Usage: "Start sessions for cp and sync", + Usage: "Manage sessions for cp and sync", Action: runSessionCmd, CustomHelpTemplate: `NAME: mc {{.Name}} - {{.Usage}} USAGE: - mc {{.Name}}{{if .Flags}} [ARGS...]{{end}} SOURCE TARGET [TARGET...] {{if .Description}} + mc {{.Name}}{{if .Flags}} [ARGS...]{{end}} [SESSION] {{if .Description}} DESCRIPTION: {{.Description}}{{end}}{{if .Flags}} diff --git a/ls.go b/ls.go index 47f77d5b..1bfaa8bd 100644 --- a/ls.go +++ b/ls.go @@ -43,9 +43,9 @@ func parseContent(c *client.Content) Content { // guess file type content.Filetype = func() string { if c.Type.IsDir() { - return "inode/directory" + return "directory" } - return "application/octet-stream" + return "file" }() content.Size = humanize.IBytes(uint64(c.Size)) diff --git a/pkg/client/fs/fs.go b/pkg/client/fs/fs.go index fe5612e6..5d29ebe9 100644 --- a/pkg/client/fs/fs.go +++ b/pkg/client/fs/fs.go @@ -194,16 +194,6 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { return } - dir, err := os.Open(fpath) - if err != nil { - contentCh <- client.ContentOnChannel{ - Content: nil, - Err: iodine.New(err, nil), - } - return - } - defer dir.Close() - fi, err := os.Stat(fpath) if err != nil { contentCh <- client.ContentOnChannel{ @@ -212,6 +202,7 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { } return } + switch fi.Mode().IsDir() { case true: // do not use ioutil.ReadDir(), since it tries to sort its @@ -219,6 +210,16 @@ func (f *fsClient) listInRoutine(contentCh chan client.ContentOnChannel) { // instead we take raw output and provide it back to the // user - this is the correct style when are moving large // quantities of files + dir, err := os.Open(fpath) + if err != nil { + contentCh <- client.ContentOnChannel{ + Content: nil, + Err: iodine.New(err, nil), + } + return + } + defer dir.Close() + files, err := dir.Readdir(-1) if err != nil { contentCh <- client.ContentOnChannel{ diff --git a/print-structs.go b/print-structs.go index dfba9c8b..f8fda1c8 100644 --- a/print-structs.go +++ b/print-structs.go @@ -48,7 +48,7 @@ func (e ErrorMessage) String() string { // Content container for content message structure type Content struct { - Filetype string `json:"content-type"` + Filetype string `json:"type"` Time string `json:"last-modified"` Size string `json:"size"` Name string `json:"name"` @@ -59,7 +59,7 @@ func (c Content) String() string { message := console.Time("[%s] ", c.Time) message = message + console.Size("%6s ", c.Size) message = func() string { - if c.Filetype == "inode/directory" { + if c.Filetype == "directory" { return message + console.Dir("%s", c.Name) } return message + console.File("%s", c.Name) diff --git a/session.go b/session.go index 520d7919..973dc52c 100644 --- a/session.go +++ b/session.go @@ -42,9 +42,9 @@ type sessionV1 struct { } func (s sessionV1) String() string { - message := console.Time("[%s] ", s.Started.Local().Format(printDate)) - message = message + console.SessionID("%s", s.SessionID) - message = message + console.Command(" [%s %s]", s.CommandType, strings.Join(s.URLs, " ")) + message := console.SessionID("%s -> ", s.SessionID) + message = message + console.Time("[%s]", s.Started.Local().Format(printDate)) + message = message + console.Command(" %s %s", s.CommandType, strings.Join(s.URLs, " ")) return message }