From d056c622bff10bff05e589d509ecc88717db4b75 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 21 Sep 2012 01:30:31 -0700 Subject: [PATCH] refactoring --- weed-fs/src/cmd/weed/volume.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/weed-fs/src/cmd/weed/volume.go b/weed-fs/src/cmd/weed/volume.go index 4fcdf06dc..ce776974a 100644 --- a/weed-fs/src/cmd/weed/volume.go +++ b/weed-fs/src/cmd/weed/volume.go @@ -128,7 +128,7 @@ func GetHandler(w http.ResponseWriter, r *http.Request) { w.Write(n.Data) } func PostHandler(w http.ResponseWriter, r *http.Request) { - r.ParseForm() + r.ParseForm() vid, _, _ := parseURLPath(r.URL.Path) volumeId, e := storage.NewVolumeId(vid) if e != nil { @@ -139,11 +139,9 @@ func PostHandler(w http.ResponseWriter, r *http.Request) { writeJson(w, r, ne) } else { ret := store.Write(volumeId, needle) - if ret > 0 || !store.HasVolume(volumeId){ //send to other replica locations + if ret > 0 || !store.HasVolume(volumeId) { //send to other replica locations if r.FormValue("type") != "standard" { - waitTime, err := strconv.Atoi(r.FormValue("wait")) - lookupResult, lookupErr := operation.Lookup(*server, volumeId) - if lookupErr == nil { + if lookupResult, lookupErr := operation.Lookup(*server, volumeId); lookupErr == nil { sendFunc := func(background bool) { postContentFunc := func(location operation.Location) bool { operation.Upload("http://"+location.PublicUrl+r.URL.Path+"?type=standard", filename, bytes.NewReader(needle.Data)) @@ -159,6 +157,7 @@ func PostHandler(w http.ResponseWriter, r *http.Request) { } } } + waitTime, err := strconv.Atoi(r.FormValue("wait")) sendFunc(err == nil && waitTime > 0) } else { log.Println("Failed to lookup for", volumeId, lookupErr.Error())