Commit 1638a80a by shenyizhong

* code review

1 parent 62264379
Showing with 12 additions and 1 deletions
...@@ -16,13 +16,14 @@ import ( ...@@ -16,13 +16,14 @@ import (
"minsync/travremot" "minsync/travremot"
_ "minsync/upload" _ "minsync/upload"
_ "net/http" _ "net/http"
"path/filepath"
"os" "os"
"runtime" "runtime"
"strings" "strings"
) )
func printUsage() { func printUsage() {
fmt.Println("Usage: seetadm --token ef0c26da821c [upload|download] src dst") fmt.Println("Usage: seetadm --token [token] [upload|download] [src] [dst]")
} }
func isValidToken(token string) (bool, error) { func isValidToken(token string) (bool, error) {
...@@ -122,6 +123,11 @@ func main() { ...@@ -122,6 +123,11 @@ func main() {
if nodetree.StrOp == "upload" { if nodetree.StrOp == "upload" {
nodetree.StrDst = "data" + nodetree.StrDst nodetree.StrDst = "data" + nodetree.StrDst
nodetree.StrSrc, err = filepath.Abs(nodetree.StrSrc)
if err != nil {
fmt.Println(err)
return
}
tmpstr := nodetree.StrSrc[:len(nodetree.StrSrc)-1] tmpstr := nodetree.StrSrc[:len(nodetree.StrSrc)-1]
idx := strings.LastIndex(tmpstr, "/") idx := strings.LastIndex(tmpstr, "/")
...@@ -157,7 +163,12 @@ func main() { ...@@ -157,7 +163,12 @@ func main() {
//out_loc.WriteTo(os.Stdout) //out_loc.WriteTo(os.Stdout)
} else if nodetree.StrOp == "download" { } else if nodetree.StrOp == "download" {
nodetree.StrDst, err = filepath.Abs(nodetree.StrDst)
nodetree.StrSrc = "data" + nodetree.StrSrc nodetree.StrSrc = "data" + nodetree.StrSrc
if err != nil {
fmt.Println(err)
return
}
// TODO, check if nodetree.StrDst is FILE or DIR // TODO, check if nodetree.StrDst is FILE or DIR
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!