ulfs

package
v1.39.6 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filesystem

type Filesystem interface {
	Close() error
	Open(ctx clingy.Context, loc ulloc.Location) (ReadHandle, error)
	Create(ctx clingy.Context, loc ulloc.Location) (WriteHandle, error)
	Remove(ctx context.Context, loc ulloc.Location) error
	ListObjects(ctx context.Context, prefix ulloc.Location, recursive bool) (ObjectIterator, error)
	ListUploads(ctx context.Context, prefix ulloc.Location, recursive bool) (ObjectIterator, error)
	IsLocalDir(ctx context.Context, loc ulloc.Location) bool
}

Filesystem represents either the local Filesystem or the data backed by a project.

type Local

type Local struct{}

Local implements something close to a filesystem but backed by the local disk.

func NewLocal

func NewLocal() *Local

NewLocal constructs a Local filesystem.

func (*Local) Create

func (l *Local) Create(ctx context.Context, path string) (WriteHandle, error)

Create makes any directories necessary to create a file at path and returns a WriteHandle.

func (*Local) IsLocalDir

func (l *Local) IsLocalDir(ctx context.Context, path string) bool

IsLocalDir returns true if the path is a directory.

func (*Local) ListObjects

func (l *Local) ListObjects(ctx context.Context, path string, recursive bool) (ObjectIterator, error)

ListObjects returns an ObjectIterator listing files and directories that have string prefix with the provided path.

func (*Local) Open

func (l *Local) Open(ctx context.Context, path string) (ReadHandle, error)

Open returns a read ReadHandle for the given local path.

func (*Local) Remove

func (l *Local) Remove(ctx context.Context, path string) error

Remove unlinks the file at the path. It is not an error if the file does not exist.

type Mixed

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

Mixed dispatches to either the local or remote filesystem depending on the location.

func NewMixed

func NewMixed(local *Local, remote *Remote) *Mixed

NewMixed returns a Mixed backed by the provided local and remote filesystems.

func (*Mixed) Close

func (m *Mixed) Close() error

Close releases any resources that the Mixed contails.

func (*Mixed) Create

func (m *Mixed) Create(ctx clingy.Context, loc ulloc.Location) (WriteHandle, error)

Create returns a WriteHandle to either a local file, remote object, or stdout.

func (*Mixed) IsLocalDir

func (m *Mixed) IsLocalDir(ctx context.Context, loc ulloc.Location) bool

IsLocalDir returns true if the location is a directory that is local.

func (*Mixed) ListObjects

func (m *Mixed) ListObjects(ctx context.Context, prefix ulloc.Location, recursive bool) (ObjectIterator, error)

ListObjects lists either files and directories with some local path prefix or remote objects with a given bucket and key.

func (*Mixed) ListUploads

func (m *Mixed) ListUploads(ctx context.Context, prefix ulloc.Location, recursive bool) (ObjectIterator, error)

ListUploads lists all of the pending uploads for remote objects with some given bucket and key.

func (*Mixed) Open

func (m *Mixed) Open(ctx clingy.Context, loc ulloc.Location) (ReadHandle, error)

Open returns a ReadHandle to either a local file, remote object, or stdin.

func (*Mixed) Remove

func (m *Mixed) Remove(ctx context.Context, loc ulloc.Location) error

Remove deletes either a local file or remote object.

type ObjectInfo

type ObjectInfo struct {
	Loc           ulloc.Location
	IsPrefix      bool
	Created       time.Time
	ContentLength int64
}

ObjectInfo is a simpler *uplink.Object that contains the minimal information the uplink command needs that multiple types can be converted to.

type ObjectIterator

type ObjectIterator interface {
	Next() bool
	Err() error
	Item() ObjectInfo
}

ObjectIterator is an interface type for iterating over objectInfo values.

type ReadHandle

type ReadHandle interface {
	io.Reader
	io.Closer
	Info() ObjectInfo
}

ReadHandle is something that can be read from.

type Remote

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

Remote implements something close to a filesystem but backed by an uplink project.

func NewRemote

func NewRemote(project *uplink.Project) *Remote

NewRemote returns something close to a filesystem and returns objects using the project.

func (*Remote) Close

func (r *Remote) Close() error

Close releases any resources that the Remote contains.

func (*Remote) Create

func (r *Remote) Create(ctx context.Context, bucket, key string) (WriteHandle, error)

Create returns a WriteHandle for the object identified by a given bucket and key.

func (*Remote) ListObjects

func (r *Remote) ListObjects(ctx context.Context, bucket, prefix string, recursive bool) ObjectIterator

ListObjects lists all of the objects in some bucket that begin with the given prefix.

func (*Remote) ListUploads

func (r *Remote) ListUploads(ctx context.Context, bucket, prefix string, recursive bool) ObjectIterator

ListUploads lists all of the pending uploads in some bucket that begin with the given prefix.

func (*Remote) Open

func (r *Remote) Open(ctx context.Context, bucket, key string) (ReadHandle, error)

Open returns a ReadHandle for the object identified by a given bucket and key.

func (*Remote) Remove

func (r *Remote) Remove(ctx context.Context, bucket, key string) error

Remove deletes the object at the provided key and bucket.

type WriteHandle

type WriteHandle interface {
	io.Writer
	Commit() error
	Abort() error
}

WriteHandle is anything that can be written to with commit/abort semantics.

Jump to

Keyboard shortcuts

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