volume: support http status 304 for the same file id

This commit is contained in:
Chris Lu
2019-04-21 13:33:23 -07:00
parent ebe94be1a1
commit 440111a349
6 changed files with 18 additions and 17 deletions

View File

@@ -111,7 +111,7 @@ func (vs *VolumeServer) VolumeTailReceiver(ctx context.Context, req *volume_serv
defer glog.V(1).Infof("receive tailing volume %d finished", v.Id)
return resp, operation.TailVolumeFromSource(req.SourceVolumeServer, vs.grpcDialOption, v.Id, req.SinceNs, int(req.IdleTimeoutSeconds), func(n *needle.Needle) error {
_, err := vs.store.Write(v.Id, n)
_, _, err := vs.store.Write(v.Id, n)
return err
})

View File

@@ -41,11 +41,14 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
}
ret := operation.UploadResult{}
_, errorStatus := topology.ReplicatedWrite(vs.GetMaster(), vs.store, volumeId, needle, r)
_, isUnchanged, writeError := topology.ReplicatedWrite(vs.GetMaster(), vs.store, volumeId, needle, r)
httpStatus := http.StatusCreated
if errorStatus != "" {
if isUnchanged {
httpStatus = http.StatusNotModified
}
if writeError != nil {
httpStatus = http.StatusInternalServerError
ret.Error = errorStatus
ret.Error = writeError.Error()
}
if needle.HasName() {
ret.Name = string(needle.Name)