예제 #1
0
func validate(cli storage.BlobStorageClient, blob string, startByte, endByte int64, data []byte) error {

	url := cli.GetBlobURL(cnt, blob)

	reader, err := cli.GetBlob(cnt, blob)
	if err != nil {
		return fmt.Errorf("Failed to read from %s: %s\n", url, err.Error())
	}

	defer reader.Close()

	dataRead, err := ioutil.ReadAll(reader)

	if err != nil {
		return fmt.Errorf("Failed to read from %s: %s\n", url, err.Error())
	}

	same := true
	for i := startByte; i <= endByte; i++ {
		if data[i] != dataRead[i] {
			same = false
		}
	}

	if !same {
		return fmt.Errorf("Failed to read data properly from %s: %s\n", url, err.Error())
	}

	return nil
}
예제 #2
0
func clearPage(cli storage.BlobStorageClient, name string, startByte, endByte int64) error {

	if err := cli.PutPage(cnt, name, startByte, endByte, storage.PageWriteTypeClear, nil); err != nil {
		url := cli.GetBlobURL(cnt, name)
		fmt.Printf("Failed to clear pages of %s: %s\n", url, err.Error())
		return err
	}
	return nil
}
예제 #3
0
func writePage(cli storage.BlobStorageClient, name string, startByte, endByte int64, chunk []byte) error {

	if err := cli.PutPage(cnt, name, startByte, endByte, storage.PageWriteTypeUpdate, chunk); err != nil {
		url := cli.GetBlobURL(cnt, name)
		fmt.Printf("Failed to write pages to %s: %s\n", url, err.Error())
		return err
	}
	return nil
}