mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
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.
This commit is contained in:
parent
a9b87c0a16
commit
4da68cfcfc
@ -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…
Reference in New Issue
Block a user