XL/erasure: fix for skipping 0 padding. (#1737)

Fixes #1736
This commit is contained in:
Krishna Srinivas
2016-05-24 20:14:32 +05:30
committed by Harshavardhana
parent 6d84e84b3c
commit b38b9fea79
3 changed files with 44 additions and 39 deletions

View File

@@ -17,19 +17,12 @@
package main
// getDataBlocks - fetches the data block only part of the input encoded blocks.
func getDataBlocks(enBlocks [][]byte, dataBlocks int) []byte {
func getDataBlocks(enBlocks [][]byte, dataBlocks int, curBlockSize int) []byte {
var data []byte
for _, block := range enBlocks[:dataBlocks] {
var newBlock []byte
// FIXME: Find a better way to skip the padding zeros.
for _, b := range block {
if b == 0 {
continue
}
newBlock = append(newBlock, b)
}
data = append(data, newBlock...)
data = append(data, block...)
}
data = data[:curBlockSize]
return data
}