From d0147a16a99c076fc7ff28c346c74b4322fa1f0c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 6 Feb 2014 11:44:54 -0800 Subject: [PATCH] avoid index out of range exception --- go/weed/weed_server/volume_server_handlers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/weed/weed_server/volume_server_handlers.go b/go/weed/weed_server/volume_server_handlers.go index 3e529e5c7..e47ac96d3 100644 --- a/go/weed/weed_server/volume_server_handlers.go +++ b/go/weed/weed_server/volume_server_handlers.go @@ -21,13 +21,13 @@ func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) { writeJsonQuiet(w, r, m) } func (vs *VolumeServer) assignVolumeHandler(w http.ResponseWriter, r *http.Request) { - err := vs.store.AddVolume(r.FormValue("volume"), r.FormValue("collection"), r.FormValue("replicationType")) + err := vs.store.AddVolume(r.FormValue("volume"), r.FormValue("collection"), r.FormValue("replication")) if err == nil { writeJsonQuiet(w, r, map[string]string{"error": ""}) } else { writeJsonQuiet(w, r, map[string]string{"error": err.Error()}) } - glog.V(2).Infoln("assign volume =", r.FormValue("volume"), ", collection =", r.FormValue("collection"), ", replicationType =", r.FormValue("replicationType"), ", error =", err) + glog.V(2).Infoln("assign volume =", r.FormValue("volume"), ", collection =", r.FormValue("collection"), ", replication =", r.FormValue("replication"), ", error =", err) } func (vs *VolumeServer) vacuumVolumeCheckHandler(w http.ResponseWriter, r *http.Request) { err, ret := vs.store.CheckCompactVolume(r.FormValue("volume"), r.FormValue("garbageThreshold")) @@ -102,7 +102,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request, if !vs.store.HasVolume(volumeId) { lookupResult, err := operation.Lookup(vs.masterNode, volumeId) glog.V(2).Infoln("volume", volumeId, "found on", lookupResult, "error", err) - if err == nil { + if err == nil && len(lookupResult.Locations)>0{ http.Redirect(w, r, "http://"+lookupResult.Locations[0].PublicUrl+r.URL.Path, http.StatusMovedPermanently) } else { glog.V(2).Infoln("lookup error:", err, r.URL.Path)