fstree

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DirNameLen is how many bytes is used to group keys into directories.
	DirNameLen = 1 // in bytes
	// MaxDepth is maximum depth of nested directories.
	MaxDepth = (sha256.Size - 1) / DirNameLen
)

Variables

View Source
var ErrFileNotFound = errors.New("file not found")

ErrFileNotFound is returned when file is missing.

Functions

This section is empty.

Types

type FSTree

type FSTree struct {
	Info

	Depth      int
	DirNameLen int
}

FSTree represents an object storage as a filesystem tree.

func (*FSTree) Delete

func (t *FSTree) Delete(addr oid.Address) error

Delete removes the object with the specified address from the storage.

func (*FSTree) Exists

func (t *FSTree) Exists(addr oid.Address) (string, error)

Exists returns the path to the file with object contents if it exists in the storage and an error otherwise.

func (*FSTree) Get

func (t *FSTree) Get(addr oid.Address) ([]byte, error)

Get returns an object from the storage by address.

func (*FSTree) Iterate

func (t *FSTree) Iterate(prm IterationPrm) error

Iterate iterates over all stored objects.

func (*FSTree) NumberOfObjects added in v0.26.1

func (t *FSTree) NumberOfObjects() (uint64, error)

NumberOfObjects walks the file tree rooted at FSTree's root and returns number of stored objects.

func (*FSTree) Put

func (t *FSTree) Put(addr oid.Address, data []byte) error

Put puts an object in the storage.

func (*FSTree) PutStream added in v0.28.0

func (t *FSTree) PutStream(addr oid.Address, handler func(*os.File) error) error

PutStream puts executes handler on a file opened for write.

type Info

type Info struct {
	// Permission bits of the root directory.
	Permissions fs.FileMode

	// Full path to the root directory.
	RootPath string
}

Info groups the information about file storage.

type IterationPrm added in v0.27.5

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

IterationPrm contains iteraction parameters.

func (*IterationPrm) WithErrorHandler added in v0.29.0

func (p *IterationPrm) WithErrorHandler(f func(oid.Address, error) error)

WithErrorHandler sets error handler for objects that cannot be read or unmarshaled.

func (*IterationPrm) WithHandler added in v0.27.5

func (p *IterationPrm) WithHandler(f func(addr oid.Address, data []byte) error)

WithHandler sets a function to call on each object.

func (*IterationPrm) WithIgnoreErrors added in v0.27.5

func (p *IterationPrm) WithIgnoreErrors(ignore bool)

WithIgnoreErrors sets a flag indicating whether errors should be ignored.

func (*IterationPrm) WithLazyHandler added in v0.28.2

func (p *IterationPrm) WithLazyHandler(f func(oid.Address, func() ([]byte, error)) error)

WithLazyHandler sets a function to call on each object. Second callback parameter opens file and reads all data to a buffer. File is not opened at all unless this callback is invoked.

Jump to

Keyboard shortcuts

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