func DeleteHandler(w http.ResponseWriter, r *http.Request) { n := new(storage.Needle) vid, fid, _ := parseURLPath(r.URL.Path) volumeId, _ := storage.NewVolumeId(vid) n.ParsePath(fid) debug("deleting", n) cookie := n.Cookie count, ok := store.Read(volumeId, n) if ok != nil { m := make(map[string]uint32) m["size"] = 0 writeJson(w, r, m) return } if n.Cookie != cookie { log.Println("delete with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent()) return } n.Size = 0 ret := store.Delete(volumeId, n) needToReplicate := !store.HasVolume(volumeId) if !needToReplicate && ret > 0 { needToReplicate = store.GetVolume(volumeId).NeedToReplicate() } if needToReplicate { //send to other replica locations if r.FormValue("type") != "standard" { if !distributedOperation(volumeId, func(location operation.Location) bool { return nil == operation.Delete("http://"+location.Url+r.URL.Path+"?type=standard") }) { ret = 0 } } } if ret != 0 { w.WriteHeader(http.StatusAccepted) } else { w.WriteHeader(http.StatusInternalServerError) } m := make(map[string]uint32) m["size"] = uint32(count) writeJson(w, r, m) }