erasure: allocate buffer only for non-nil disk (#1811)

This commit is contained in:
Bala FA 2016-06-01 00:25:50 +05:30 committed by Harshavardhana
parent 89f65333fb
commit db2fdbf38d

View File

@ -34,12 +34,11 @@ func (e erasure) ReadFile(volume, path string, startOffset int64, buffer []byte)
// Read from all the disks.
for index, disk := range e.storageDisks {
blockIndex := e.distribution[index] - 1
// Initialize shard slice and fill the data from each parts.
enBlocks[blockIndex] = make([]byte, curEncBlockSize)
if disk == nil {
enBlocks[blockIndex] = nil
continue
}
// Initialize shard slice and fill the data from each parts.
enBlocks[blockIndex] = make([]byte, curEncBlockSize)
// Read the necessary blocks.
_, err := disk.ReadFile(volume, path, offsetEncOffset, enBlocks[blockIndex])
if err != nil {