fix: Merge() should merge and return a copy (#11714)

fixes #11713
This commit is contained in:
Harshavardhana 2021-03-05 09:42:46 -08:00 committed by GitHub
parent 124816f6a6
commit 651487507a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,14 +97,15 @@ func (d1 BackendDisks) Merge(d2 BackendDisks) BackendDisks {
if len(d2) == 0 { if len(d2) == 0 {
d2 = make(BackendDisks) d2 = make(BackendDisks)
} }
var merged = make(BackendDisks)
for i1, v1 := range d1 { for i1, v1 := range d1 {
if v2, ok := d2[i1]; ok { if v2, ok := d2[i1]; ok {
d2[i1] = v2 + v1 merged[i1] = v2 + v1
continue continue
} }
d2[i1] = v1 merged[i1] = v1
} }
return d2 return merged
} }
// StorageInfo - Connect to a minio server and call Storage Info Management API // StorageInfo - Connect to a minio server and call Storage Info Management API