From 0af6d65d4002bf075db70acc363f7b24ff345ef7 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Thu, 3 Oct 2019 16:24:59 -0400 Subject: [PATCH] rename FileStore -> DiskStore --- cmd/getstream.go | 2 +- store/file.go | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/getstream.go b/cmd/getstream.go index 5d1f6d6..90990f1 100644 --- a/cmd/getstream.go +++ b/cmd/getstream.go @@ -30,7 +30,7 @@ func getStreamCmd(cmd *cobra.Command, args []string) { s := store.NewCachingBlobStore( peer.NewStore(addr), - store.NewFileBlobStore("/tmp/lbry_downloaded_blobs", 2), + store.NewDiskBlobStore("/tmp/lbry_downloaded_blobs", 2), ) wd, err := os.Getwd() diff --git a/store/file.go b/store/file.go index cc049b0..c47772c 100644 --- a/store/file.go +++ b/store/file.go @@ -8,8 +8,8 @@ import ( "github.com/lbryio/lbry.go/extras/errors" ) -// FileBlobStore is a local disk store. -type FileBlobStore struct { +// DiskBlobStore stores blobs on a local disk +type DiskBlobStore struct { // the location of blobs on disk blobDir string // store files in subdirectories based on the first N chars in the filename. 0 = don't create subdirectories. @@ -18,27 +18,27 @@ type FileBlobStore struct { initialized bool } -// NewFileBlobStore returns an initialized file disk store pointer. -func NewFileBlobStore(dir string, prefixLength int) *FileBlobStore { - return &FileBlobStore{blobDir: dir, prefixLength: prefixLength} +// NewDiskBlobStore returns an initialized file disk store pointer. +func NewDiskBlobStore(dir string, prefixLength int) *DiskBlobStore { + return &DiskBlobStore{blobDir: dir, prefixLength: prefixLength} } -func (f *FileBlobStore) dir(hash string) string { +func (f *DiskBlobStore) dir(hash string) string { if f.prefixLength <= 0 || len(hash) < f.prefixLength { return f.blobDir } return path.Join(f.blobDir, hash[:f.prefixLength]) } -func (f *FileBlobStore) path(hash string) string { +func (f *DiskBlobStore) path(hash string) string { return path.Join(f.dir(hash), hash) } -func (f *FileBlobStore) ensureDirExists(dir string) error { +func (f *DiskBlobStore) ensureDirExists(dir string) error { return errors.Err(os.MkdirAll(dir, 0755)) } -func (f *FileBlobStore) initOnce() error { +func (f *DiskBlobStore) initOnce() error { if f.initialized { return nil } @@ -53,7 +53,7 @@ func (f *FileBlobStore) initOnce() error { } // Has returns T/F or Error if it the blob stored already. It will error with any IO disk error. -func (f *FileBlobStore) Has(hash string) (bool, error) { +func (f *DiskBlobStore) Has(hash string) (bool, error) { err := f.initOnce() if err != nil { return false, err @@ -70,7 +70,7 @@ func (f *FileBlobStore) Has(hash string) (bool, error) { } // Get returns the byte slice of the blob stored or will error if the blob doesn't exist. -func (f *FileBlobStore) Get(hash string) ([]byte, error) { +func (f *DiskBlobStore) Get(hash string) ([]byte, error) { err := f.initOnce() if err != nil { return nil, err @@ -88,7 +88,7 @@ func (f *FileBlobStore) Get(hash string) ([]byte, error) { } // Put stores the blob on disk -func (f *FileBlobStore) Put(hash string, blob []byte) error { +func (f *DiskBlobStore) Put(hash string, blob []byte) error { err := f.initOnce() if err != nil { return err @@ -103,12 +103,12 @@ func (f *FileBlobStore) Put(hash string, blob []byte) error { } // PutSD stores the sd blob on the disk -func (f *FileBlobStore) PutSD(hash string, blob []byte) error { +func (f *DiskBlobStore) PutSD(hash string, blob []byte) error { return f.Put(hash, blob) } // Delete deletes the blob from the store -func (f *FileBlobStore) Delete(hash string) error { +func (f *DiskBlobStore) Delete(hash string) error { err := f.initOnce() if err != nil { return err