filestore

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error is the default filestore error class
	Error = errs.Class("filestore error")
)

Functions

This section is empty.

Types

type Dir

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

Dir represents single folder for storing blobs

func NewDir

func NewDir(path string) (*Dir, error)

NewDir returns folder for storing blobs

func (*Dir) Commit

func (dir *Dir) Commit(ctx context.Context, file *os.File, ref storage.BlobRef) (err error)

Commit commits temporary file to the permanent storage

func (*Dir) CreateTemporaryFile

func (dir *Dir) CreateTemporaryFile(ctx context.Context, prealloc int64) (_ *os.File, err error)

CreateTemporaryFile creates a preallocated temporary file in the temp directory prealloc preallocates file to make writing faster

func (*Dir) Delete

func (dir *Dir) Delete(ctx context.Context, ref storage.BlobRef) (err error)

Delete deletes file with the specified ref

func (*Dir) DeleteTemporary

func (dir *Dir) DeleteTemporary(ctx context.Context, file *os.File) (err error)

DeleteTemporary deletes a temporary file

func (*Dir) GarbageCollect

func (dir *Dir) GarbageCollect(ctx context.Context) (err error)

GarbageCollect collects files that are pending deletion

func (*Dir) Info

func (dir *Dir) Info() (DiskInfo, error)

Info returns information about the current state of the dir

func (*Dir) Open

func (dir *Dir) Open(ctx context.Context, ref storage.BlobRef) (_ *os.File, err error)

Open opens the file with the specified ref

func (*Dir) Path

func (dir *Dir) Path() string

Path returns the directory path

type DiskInfo

type DiskInfo struct {
	ID             string
	AvailableSpace int64
}

DiskInfo contains statistics about this dir

type Store

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

Store implements a blob store

func New

func New(dir *Dir) *Store

New creates a new disk blob store in the specified directory

func NewAt

func NewAt(path string) (*Store, error)

NewAt creates a new disk blob store in the specified directory

func (*Store) Close

func (store *Store) Close() error

Close closes the store.

func (*Store) Create

func (store *Store) Create(ctx context.Context, ref storage.BlobRef, size int64) (_ storage.BlobWriter, err error)

Create creates a new blob that can be written optionally takes a size argument for performance improvements, -1 is unknown size

func (*Store) Delete

func (store *Store) Delete(ctx context.Context, ref storage.BlobRef) (err error)

Delete deletes blobs with the specified ref

func (*Store) FreeSpace

func (store *Store) FreeSpace() (int64, error)

FreeSpace returns how much space left in underlying directory

func (*Store) GarbageCollect

func (store *Store) GarbageCollect(ctx context.Context) (err error)

GarbageCollect tries to delete any files that haven't yet been deleted

func (*Store) Open

func (store *Store) Open(ctx context.Context, ref storage.BlobRef) (_ storage.BlobReader, err error)

Open loads blob with the specified hash

Jump to

Keyboard shortcuts

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