parent
9744efc725
commit
58a04ee831
@ -1,61 +1,65 @@ |
|||||||
package main |
package main |
||||||
|
|
||||||
import ( |
// +build ignore
|
||||||
"bytes" |
func main() {} |
||||||
"fmt" |
|
||||||
"os" |
|
||||||
"reflect" |
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkg/storage/donut/v1" |
//
|
||||||
) |
//import (
|
||||||
|
// "bytes"
|
||||||
func main() { |
// "fmt"
|
||||||
fmt.Println("--start") |
// "os"
|
||||||
|
// "reflect"
|
||||||
file, err := os.OpenFile("hello", os.O_WRONLY|os.O_CREATE, 0666) |
//
|
||||||
if err != nil { |
// "github.com/minio-io/minio/pkg/storage/donut/v1"
|
||||||
panic(err) |
//)
|
||||||
} |
//
|
||||||
donut := v1.New(file) |
//func main() {
|
||||||
|
// fmt.Println("--start")
|
||||||
gobHeader := v1.GobHeader{} |
//
|
||||||
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.") |
// file, err := os.OpenFile("newfile", os.O_WRONLY|os.O_CREATE, 0666)
|
||||||
|
// if err != nil {
|
||||||
dataBuffer := bytes.NewBuffer(data) |
// panic(err)
|
||||||
err = donut.Write(gobHeader, dataBuffer) |
// }
|
||||||
if err != nil { |
// donut := v1.Write(file)
|
||||||
panic(err) |
//
|
||||||
} |
// gobHeader := v1.GobHeader{}
|
||||||
file.Close() |
// data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
|
||||||
fmt.Println("--closed") |
//
|
||||||
|
// dataBuffer := bytes.NewBuffer(data)
|
||||||
fmt.Println("--verify") |
// err = donut.Write(gobHeader, dataBuffer)
|
||||||
stat, _ := os.Stat("hello") |
// if err != nil {
|
||||||
fileSize := stat.Size() |
// panic(err)
|
||||||
|
// }
|
||||||
rfile, _ := os.OpenFile("hello", os.O_RDONLY, 0666) |
// file.Close()
|
||||||
blockStart := make([]byte, 4) |
// fmt.Println("--closed")
|
||||||
blockStartCheck := []byte{'M', 'I', 'N', 'I'} |
//
|
||||||
|
// fmt.Println("--verify")
|
||||||
_, err = rfile.Read(blockStart) |
// stat, _ := os.Stat("newfile")
|
||||||
if err != nil { |
// fileSize := stat.Size()
|
||||||
panic(err) |
//
|
||||||
} |
// rfile, _ := os.OpenFile("newfile", os.O_RDONLY, 0666)
|
||||||
|
// blockStart := make([]byte, 4)
|
||||||
blockEnd := make([]byte, 4) |
// blockStartCheck := []byte{'M', 'I', 'N', 'I'}
|
||||||
start := fileSize - 4 |
//
|
||||||
blockEndCheck := []byte{'I', 'N', 'I', 'M'} |
// _, err = rfile.Read(blockStart)
|
||||||
rfile.ReadAt(blockEnd, start) |
// if err != nil {
|
||||||
rfile.Close() |
// panic(err)
|
||||||
|
// }
|
||||||
if !reflect.DeepEqual(blockStart, blockStartCheck) { |
//
|
||||||
panic("Corrupted donut file") |
// blockEnd := make([]byte, 4)
|
||||||
} |
// start := fileSize - 4
|
||||||
|
// blockEndCheck := []byte{'I', 'N', 'I', 'M'}
|
||||||
if !reflect.DeepEqual(blockEnd, blockEndCheck) { |
// rfile.ReadAt(blockEnd, start)
|
||||||
panic("Corrupted donut file") |
// rfile.Close()
|
||||||
} |
//
|
||||||
|
// if !reflect.DeepEqual(blockStart, blockStartCheck) {
|
||||||
fmt.Println("--verified") |
// panic("Corrupted donut file")
|
||||||
fmt.Println("--end") |
// }
|
||||||
} |
//
|
||||||
|
// if !reflect.DeepEqual(blockEnd, blockEndCheck) {
|
||||||
|
// panic("Corrupted donut file")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// fmt.Println("--verified")
|
||||||
|
// fmt.Println("--end")
|
||||||
|
//}
|
||||||
|
Loading…
Reference in new issue