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) {
func main() {
fmt.Println("seetadm v0.0.3")
fmt.Println("seetadm v0.0.4")
if len(os.Args) < 6 {
printUsage()
......@@ -113,6 +113,7 @@ func main() {
fmt.Println(err)
return
}
nodetree.StrSrc += "/"
tmpstr := nodetree.StrSrc[:len(nodetree.StrSrc)-1]
idx := strings.LastIndex(tmpstr, "/")
......@@ -149,6 +150,12 @@ func main() {
} else if nodetree.StrOp == "download" {
nodetree.StrDst, err = filepath.Abs(nodetree.StrDst)
if err != nil {
fmt.Println(err)
return
}
nodetree.StrDst += "/"
nodetree.StrSrc = "data" + nodetree.StrSrc
if err != nil {
fmt.Println(err)
......@@ -159,9 +166,16 @@ func main() {
var option_remot nodetree.OptionRemot
option_remot.RootPath = []string{nodetree.StrSrc}
resp_remot, err := travremot.Explorer(option_remot)
resp_remot, res, err := travremot.Explorer(option_remot)
if err != nil {
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)
......
......@@ -19,7 +19,7 @@ func init() {
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
......@@ -32,12 +32,17 @@ func Explorer(option nodetree.OptionRemot) (nodetree.NodeRemot, error) {
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)
}
return root, nil
return root, def.SUCCESS, nil
}
func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (def.ErrCode, error) {
......@@ -77,6 +82,10 @@ func exploreRecursive(node *nodetree.NodeRemot, option *nodetree.OptionRemot) (d
var jsonRes nodetree.DataRemot
json.Unmarshal(body, &jsonRes)
if jsonRes.Msg == "user do not login" {
return def.ERR_NOT_LOGIN, nil
}
url = "http://"
url += nodetree.StrHost
url += ":"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!