Merge pull request #8438 from wy65701436/fix-quota-bug

Fix logic error in quota middlewware on handling failure response
This commit is contained in:
Wang Yan 2019-07-29 16:02:57 +08:00 committed by GitHub
commit ca20281b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -155,7 +155,7 @@ func (pmi *PutManifestInterceptor) HandleResponse(rw util.CustomResponseWriter,
} }
} }
} else if rw.Status() >= 300 || rw.Status() <= 511 { } else if rw.Status() >= 300 && rw.Status() <= 511 {
if !mf.Exist { if !mf.Exist {
success := util.TryFreeQuota(mf.ProjectID, mf.Quota) success := util.TryFreeQuota(mf.ProjectID, mf.Quota)
if !success { if !success {

View File

@ -175,7 +175,7 @@ func HandleBlobCommon(rw util.CustomResponseWriter, req *http.Request) error {
if err != nil { if err != nil {
return err return err
} }
} else if rw.Status() >= 300 || rw.Status() <= 511 { } else if rw.Status() >= 300 && rw.Status() <= 511 {
success := util.TryFreeQuota(bb.ProjectID, bb.Quota) success := util.TryFreeQuota(bb.ProjectID, bb.Quota)
if !success { if !success {
return fmt.Errorf("Error to release resource booked for the blob, %d, digest: %s ", bb.ProjectID, bb.Digest) return fmt.Errorf("Error to release resource booked for the blob, %d, digest: %s ", bb.ProjectID, bb.Digest)