func (d *DiskStore) Put(hash string, blob stream.Blob) error {
	err := d.initOnce()
	if err != nil {
		return err
	}
	err = d.ensureDirExists(d.dir(hash))
	if err != nil {
		return err
	}
	f, err := os.OpenFile(d.tmpPath(hash), openFileFlags, 0644)
	if err != nil {
		return errors.Err(err)
	}
	defer f.Close()
	dio, err := directio.New(f)
	if err != nil {
		return errors.Err(err)
	}
	defer dio.Flush()
	_, err = io.Copy(dio, bytes.NewReader(blob))
	if err != nil {
		return errors.Err(err)
	}
	err = os.Rename(d.tmpPath(hash), d.path(hash))
	return errors.Err(err)
}
Put stores the blob on disk
package store
import (
	"bytes"
	"io"
	"io/ioutil"
	"os"
	"path"
	"time"
	"github.com/lbryio/reflector.go/shared"
	"github.com/lbryio/reflector.go/store/speedwalk"
	"github.com/lbryio/lbry.go/v2/extras/errors"
	"github.com/lbryio/lbry.go/v2/stream"
	"github.com/brk0v/directio"
)
type DiskStore struct {
	blobDir string
	prefixLength int
	initialized bool
}
func NewDiskStore(dir string, prefixLength int) *DiskStore {
	return &DiskStore{
		blobDir:      dir,
		prefixLength: prefixLength,
	}
}
const nameDisk = "disk"
func (d *DiskStore) Name() string { return nameDisk }
func (d *DiskStore) Has(hash string) (bool, error) {
	err := d.initOnce()
	if err != nil {
		return false, err
	}
	_, err = os.Stat(d.path(hash))
	if err != nil {
		if os.IsNotExist(err) {
			return false, nil
		}
		return false, errors.Err(err)
	}
	return true, nil
}
func (d *DiskStore) Get(hash string) (stream.Blob, shared.BlobTrace, error) {
	start := time.Now()
	err := d.initOnce()
	if err != nil {
		return nil, shared.NewBlobTrace(time.Since(start), d.Name()), err
	}
	blob, err := ioutil.ReadFile(d.path(hash))
	if err != nil {
		if os.IsNotExist(err) {
			return nil, shared.NewBlobTrace(time.Since(start), d.Name()), errors.Err(ErrBlobNotFound)
		}
		return nil, shared.NewBlobTrace(time.Since(start), d.Name()), errors.Err(err)
	}
	return blob, shared.NewBlobTrace(time.Since(start), d.Name()), nil
}