filereader

package
v0.0.0-...-b178995 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SEEK_SET int = 0 // seek relative to the origin of the file
	SEEK_CUR int = 1 // seek relative to the current offset
	SEEK_END int = 2 // seek relative to the end
)

Variables

This section is empty.

Functions

func GetFile

func GetFile(ctx context.Context, bs BlobStore, hash, path string) error

Download a file by its hash to path

Types

type BlobStore

type BlobStore interface {
	Get(context.Context, string) ([]byte, error)
}

type File

type File struct {
	// contains filtered or unexported fields
}

File implements io.Reader, and io.ReaderAt. It fetch blobs on the fly.

func NewFile

func NewFile(ctx context.Context, bs BlobStore, meta *node.RawNode, cache *lru.Cache) (f *File)

NewFile creates a new File instance.

func NewFileRemote

func NewFileRemote(ctx context.Context, bs BlobStore, meta *node.RawNode, ivs []*node.IndexValue, cache *lru.Cache) (f *File)

NewFileRemote creates a new File instance that will fetch chunks from the remote storage, and uses BlobStash as a indexer only

func (*File) Close

func (f *File) Close() error

Close implements io.Closer

func (*File) PreloadChunks

func (f *File) PreloadChunks()

PreloadChunks all the chunks in a goroutine

func (*File) PurgeCache

func (f *File) PurgeCache() error

PurgeCache purges the in-mem chunk cache

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

Read implements io.Reader

func (*File) ReadAt

func (f *File) ReadAt(p []byte, offset int64) (n int, err error)

ReadAt implements the io.ReaderAt interface

func (*File) Reset

func (f *File) Reset()

Reset resets the offset to 0

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek implements io.Seeker

type IndexValue

type IndexValue struct {
	Index int64
	Value string
	I     int
}

IndexValue represents a file chunk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL