Fix healing whole file bitrot (#7123)

* Use 0-byte file for bitrot verification of whole-file-bitrot files

Also pass the right checksum information for bitrot verification

* Copy xlMeta info from latest meta except []checksums and []Parts while healing
This commit is contained in:
Krishna Srinivas
2019-01-19 18:28:40 -08:00
committed by Harshavardhana
parent 74c2048ea9
commit 51ec61ee94
4 changed files with 20 additions and 29 deletions

View File

@@ -24,7 +24,7 @@ import (
"testing"
)
func TestBitrotReaderWriter(t *testing.T) {
func testBitrotReaderWriterAlgo(t *testing.T, bitrotAlgo BitrotAlgorithm) {
tmpDir, err := ioutil.TempDir("", "")
if err != nil {
log.Fatal(err)
@@ -41,7 +41,7 @@ func TestBitrotReaderWriter(t *testing.T) {
disk.MakeVol(volume)
writer := newBitrotWriter(disk, volume, filePath, 35, HighwayHash256S, 10)
writer := newBitrotWriter(disk, volume, filePath, 35, bitrotAlgo, 10)
_, err = writer.Write([]byte("aaaaaaaaaa"))
if err != nil {
@@ -61,7 +61,7 @@ func TestBitrotReaderWriter(t *testing.T) {
}
writer.(io.Closer).Close()
reader := newStreamingBitrotReader(disk, volume, filePath, 35, HighwayHash256S, 10)
reader := newBitrotReader(disk, volume, filePath, 35, bitrotAlgo, bitrotWriterSum(writer), 10)
b := make([]byte, 10)
if _, err = reader.ReadAt(b, 0); err != nil {
log.Fatal(err)
@@ -76,3 +76,9 @@ func TestBitrotReaderWriter(t *testing.T) {
log.Fatal(err)
}
}
func TestAllBitrotAlgorithms(t *testing.T) {
for bitrotAlgo := range bitrotAlgorithms {
testBitrotReaderWriterAlgo(t, bitrotAlgo)
}
}