Merge pull request #845 from harshavardhana/pr_out_mc_session_related_changes
mc session related changes
This commit is contained in:
+2
-2
@@ -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}}
|
||||
|
||||
@@ -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))
|
||||
|
||||
+11
-10
@@ -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{
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
+3
-3
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user