Commit f351eb69 by Sayes

* code review

1 parent 6124dc0a
Showing with 20 additions and 2 deletions
...@@ -155,7 +155,7 @@ func Upload(node *nodetree.NodeLoc) { ...@@ -155,7 +155,7 @@ func Upload(node *nodetree.NodeLoc) {
if opBytes, err := ioutil.ReadAll(stdout); err != nil { if opBytes, err := ioutil.ReadAll(stdout); err != nil {
log.Fatal(err) log.Fatal(err)
} else { } else {
fmt.Printf("File uploaded successful : [%v] -> [%v]\n", node.Path, nodetree.StrDst+tmpStrs[1]) fmt.Printf("[%v]\n", node.Path)
log.Println(string(opBytes)) log.Println(string(opBytes))
} }
} }
...@@ -235,6 +235,8 @@ func Download(node *nodetree.NodeRemot) error { ...@@ -235,6 +235,8 @@ func Download(node *nodetree.NodeRemot) error {
log.Printf("wget -O %v \"%v\"", strDstFile, jsonRes.Data.Url) log.Printf("wget -O %v \"%v\"", strDstFile, jsonRes.Data.Url)
fmt.Printf("[%v] ", strDstFile)
res, err := http.Get(jsonRes.Data.Url) res, err := http.Get(jsonRes.Data.Url)
if err != nil { if err != nil {
fmt.Println("error occurred!") fmt.Println("error occurred!")
...@@ -252,7 +254,7 @@ func Download(node *nodetree.NodeRemot) error { ...@@ -252,7 +254,7 @@ func Download(node *nodetree.NodeRemot) error {
writer := bufio.NewWriter(file) writer := bufio.NewWriter(file)
written, _ := io.Copy(writer, reader) written, _ := io.Copy(writer, reader)
fmt.Printf("File download successful : [%v] -> [%v], %v written\n", nodetree.StrSrc+tmpStrs[1], strDstFile, written) fmt.Printf("%v bytes\n", written)
return nil return nil
} }
...@@ -71,6 +71,22 @@ func main() { ...@@ -71,6 +71,22 @@ func main() {
return return
} }
if nodetree.StrOp == "download" {
_, err := os.Lstat(nodetree.StrDst)
if os.IsNotExist(err) {
fmt.Printf("target path [%v] not exist\n", nodetree.StrDst)
return
}
}
if nodetree.StrOp == "upload" {
_, err := os.Lstat(nodetree.StrSrc)
if os.IsNotExist(err) {
fmt.Printf("source path [%v] not exist\n", nodetree.StrSrc)
return
}
}
_, err := os.Lstat(nodetree.StrToken) _, err := os.Lstat(nodetree.StrToken)
if !os.IsNotExist(err) { if !os.IsNotExist(err) {
data, err := ioutil.ReadFile(nodetree.StrToken) data, err := ioutil.ReadFile(nodetree.StrToken)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!