Commit aa925ec0 by shenyizhong

* code review

1 parent 7e265479
Showing with 28 additions and 5 deletions
...@@ -32,7 +32,7 @@ func isValidToken(token string) (bool, error) { ...@@ -32,7 +32,7 @@ func isValidToken(token string) (bool, error) {
func main() { func main() {
fmt.Println("seetadm v0.0.3") fmt.Println("seetadm v0.0.4")
if len(os.Args) < 6 { if len(os.Args) < 6 {
printUsage() printUsage()
...@@ -113,6 +113,7 @@ func main() { ...@@ -113,6 +113,7 @@ func main() {
fmt.Println(err) fmt.Println(err)
return return
} }
nodetree.StrSrc += "/"
tmpstr := nodetree.StrSrc[:len(nodetree.StrSrc)-1] tmpstr := nodetree.StrSrc[:len(nodetree.StrSrc)-1]
idx := strings.LastIndex(tmpstr, "/") idx := strings.LastIndex(tmpstr, "/")
...@@ -149,6 +150,12 @@ func main() { ...@@ -149,6 +150,12 @@ func main() {
} else if nodetree.StrOp == "download" { } else if nodetree.StrOp == "download" {
nodetree.StrDst, err = filepath.Abs(nodetree.StrDst) nodetree.StrDst, err = filepath.Abs(nodetree.StrDst)
if err != nil {
fmt.Println(err)
return
}
nodetree.StrDst += "/"
nodetree.StrSrc = "data" + nodetree.StrSrc nodetree.StrSrc = "data" + nodetree.StrSrc
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
...@@ -159,9 +166,16 @@ func main() { ...@@ -159,9 +166,16 @@ func main() {
var option_remot nodetree.OptionRemot var option_remot nodetree.OptionRemot
option_remot.RootPath = []string{nodetree.StrSrc} option_remot.RootPath = []string{nodetree.StrSrc}
resp_remot, err := travremot.Explorer(option_remot) resp_remot, res, err := travremot.Explorer(option_remot)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
fmt.Println("there are something wrong, check logger please")
return
} else if res != def.SUCCESS {
if res == def.ERR_NOT_LOGIN {
fmt.Println("invalid token")
}
return
} }
b_remot, err := json.Marshal(resp_remot) b_remot, err := json.Marshal(resp_remot)
......
...@@ -19,7 +19,7 @@ func init() { ...@@ -19,7 +19,7 @@ func init() {
log.Println("minsync.travremot.init() called") log.Println("minsync.travremot.init() called")
} }
func Explorer(option nodetree.OptionRemot) (nodetree.NodeRemot, error) { func Explorer(option nodetree.OptionRemot) (nodetree.NodeRemot, def.ErrCode, error) {
var root nodetree.NodeRemot var root nodetree.NodeRemot
...@@ -32,12 +32,17 @@ func Explorer(option nodetree.OptionRemot) (nodetree.NodeRemot, error) { ...@@ -32,12 +32,17 @@ func Explorer(option nodetree.OptionRemot) (nodetree.NodeRemot, error) {
child.Name = p child.Name = p
exploreRecursive(&child, &option) res, err := exploreRecursive(&child, &option)
if err != nil {
return root, res, err
} else if res != def.SUCCESS {
return root, res, nil
}
root.Children = append(root.Children, &child) root.Children = append(root.Children, &child)
} }
return root, nil return root, def.SUCCESS, nil
} }
func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (def.ErrCode, error) { func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (def.ErrCode, error) {
...@@ -77,6 +82,10 @@ func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (d ...@@ -77,6 +82,10 @@ func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (d
var jsonRes nodetree.DataRemot var jsonRes nodetree.DataRemot
json.Unmarshal(body, &jsonRes) json.Unmarshal(body, &jsonRes)
if jsonRes.Msg == "user do not login" {
return def.ERR_NOT_LOGIN, nil
}
url = "http://" url = "http://"
url += nodetree.StrHost url += nodetree.StrHost
url += ":" url += ":"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!