Handle indexes correctly in DeleteMultipleObjectsHandler (#8544)

Regression from #8509 which changes objectsToDelete entry
from a list to map. This will cause index out of range
panic if object is not selected for delete.
master
poornas 5 years ago committed by Harshavardhana
parent a9b87c0a16
commit 4da68cfcfc
  1. 14
      cmd/bucket-handlers.go

@ -404,20 +404,24 @@ func (api objectAPIHandlers) DeleteMultipleObjectsHandler(w http.ResponseWriter,
toNames := func(input map[string]int) (output []string) { toNames := func(input map[string]int) (output []string) {
output = make([]string, len(input)) output = make([]string, len(input))
for name, index := range input { idx := 0
output[index] = name for name := range input {
output[idx] = name
idx++
} }
return return
} }
errs, err := deleteObjectsFn(ctx, bucket, toNames(objectsToDelete)) deleteList := toNames(objectsToDelete)
errs, err := deleteObjectsFn(ctx, bucket, deleteList)
if err != nil { if err != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r)) writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
return return
} }
for _, index := range objectsToDelete { for i, objName := range deleteList {
dErrs[index] = toAPIErrorCode(ctx, errs[index]) dIdx := objectsToDelete[objName]
dErrs[dIdx] = toAPIErrorCode(ctx, errs[i])
} }
// Collect deleted objects and errors if any. // Collect deleted objects and errors if any.

Loading…
Cancel
Save