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

@@ -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)