Exemple #1
0
func WriteVersionedBlobRA(bs blobstore.RandomAccessBlobStore, blobpath string, version byte) error {
	bh, err := bs.Open(blobpath, flags.O_RDWRCREATE)
	if err != nil {
		return fmt.Errorf("Failed to open handle: %v", err)
	}
	if err := bh.PWrite([]byte{version}, 0); err != nil {
		return fmt.Errorf("Failed to blob write: %v", err)
	}
	if err := bh.Close(); err != nil {
		return fmt.Errorf("Failed to close handle: %v", err)
	}

	return nil
}
Exemple #2
0
func AssertBlobVersionRA(bs blobstore.RandomAccessBlobStore, blobpath string, expected version.Version) error {
	h, err := bs.Open(blobpath, flags.O_RDONLY)
	if err != nil {
		return fmt.Errorf("Failed to open reader: %v", err)
	}
	actual, err := TestQueryVersion(&blobstore.OffsetReader{h, 0})
	if err != nil {
		return fmt.Errorf("Failed to query version: %v", err)
	}
	if err := h.Close(); err != nil {
		return fmt.Errorf("Failed to close reader: %v", err)
	}

	if actual != expected {
		return fmt.Errorf("Expected version %d, but got %d", expected, actual)
	}

	return nil
}