filestore

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("filestore error")

Error is the default filestore error class

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(file *os.File, ref storage.BlobRef) error

Commit commits temporary file to the permanent storage

func (*Dir) CreateTemporaryFile

func (dir *Dir) CreateTemporaryFile(prealloc int64) (*os.File, 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(ref storage.BlobRef) error

Delete deletes file with the specified ref

func (*Dir) DeleteTemporary

func (dir *Dir) DeleteTemporary(file *os.File) error

DeleteTemporary deletes a temporary file

func (*Dir) GarbageCollect

func (dir *Dir) GarbageCollect() 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(ref storage.BlobRef) (*os.File, 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, 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) 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) 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, 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