ulfs

package
v1.54.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOptions added in v1.51.1

type CreateOptions struct {
	Expires time.Time
}

CreateOptions contains extra options to create an object.

type Filesystem

type Filesystem interface {
	Close() error
	Open(ctx clingy.Context, loc ulloc.Location) (MultiReadHandle, error)
	Create(ctx clingy.Context, loc ulloc.Location, opts *CreateOptions) (MultiWriteHandle, error)
	Move(ctx clingy.Context, source, dest ulloc.Location) error
	Copy(ctx clingy.Context, source, dest ulloc.Location) error
	Remove(ctx context.Context, loc ulloc.Location, opts *RemoveOptions) error
	List(ctx context.Context, prefix ulloc.Location, opts *ListOptions) (ObjectIterator, error)
	IsLocalDir(ctx context.Context, loc ulloc.Location) bool
	Stat(ctx context.Context, loc ulloc.Location) (*ObjectInfo, error)
}

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

type GenericMultiReadHandle

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

GenericMultiReadHandle can turn any GenericReader into a MultiReadHandle.

func NewGenericMultiReadHandle

func NewGenericMultiReadHandle(r GenericReader, info ObjectInfo) *GenericMultiReadHandle

NewGenericMultiReadHandle implements MultiReadHandle for *os.Files.

func (*GenericMultiReadHandle) Close

func (o *GenericMultiReadHandle) Close() error

Close closes the GenericMultiReadHandle.

func (*GenericMultiReadHandle) Info

Info returns the object info.

func (*GenericMultiReadHandle) NextPart

func (o *GenericMultiReadHandle) NextPart(ctx context.Context, length int64) (ReadHandle, error)

NextPart returns a ReadHandle of length bytes at the current offset.

func (*GenericMultiReadHandle) SetOffset

func (o *GenericMultiReadHandle) SetOffset(offset int64) error

SetOffset will set the offset for the next call to NextPart.

type GenericMultiWriteHandle

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

GenericMultiWriteHandle implements MultiWriteHandle for *os.Files.

func NewGenericMultiWriteHandle

func NewGenericMultiWriteHandle(w GenericWriter) *GenericMultiWriteHandle

NewGenericMultiWriteHandle constructs an *GenericMultiWriteHandle from a GenericWriter.

func (*GenericMultiWriteHandle) Abort

Abort aborts the overall GenericMultiWriteHandle.

func (*GenericMultiWriteHandle) Commit

Commit commits the overall GenericMultiWriteHandle. It errors if any parts were aborted.

func (*GenericMultiWriteHandle) NextPart

func (o *GenericMultiWriteHandle) NextPart(ctx context.Context, length int64) (WriteHandle, error)

NextPart returns a WriteHandle expecting length bytes to be written to it.

type GenericReader

type GenericReader interface {
	io.Closer
	io.ReaderAt
}

GenericReader is an interface that can be turned into a GenericMultiReadHandle.

type GenericWriter

type GenericWriter interface {
	io.WriterAt
	Commit() error
	Abort() error
}

GenericWriter is an interface that can be turned into a GenericMultiWriteHandle.

type ListOptions

type ListOptions struct {
	Recursive bool
	Pending   bool
	Expanded  bool
}

ListOptions describes options to the List command.

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) Copy added in v1.53.1

func (l *Local) Copy(ctx context.Context, oldpath, newpath string) error

Copy copies file to provided path.

func (*Local) Create

func (l *Local) Create(ctx context.Context, path string) (MultiWriteHandle, 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) List

func (l *Local) List(ctx context.Context, path string, opts *ListOptions) (ObjectIterator, error)

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

func (*Local) Move

func (l *Local) Move(ctx context.Context, oldpath, newpath string) error

Move moves file to provided path.

func (*Local) Open

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

Open returns a read ReadHandle for the given local path.

func (*Local) Remove

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

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

func (*Local) Stat

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

Stat returns an ObjectInfo describing the provided path.

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) Copy added in v1.53.1

func (m *Mixed) Copy(ctx clingy.Context, source, dest ulloc.Location) error

Copy copies either a local file or remote object.

func (*Mixed) Create

func (m *Mixed) Create(ctx clingy.Context, loc ulloc.Location, opts *CreateOptions) (MultiWriteHandle, 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) List

func (m *Mixed) List(ctx context.Context, prefix ulloc.Location, opts *ListOptions) (ObjectIterator, error)

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

func (*Mixed) Move

func (m *Mixed) Move(ctx clingy.Context, source, dest ulloc.Location) error

Move moves either a local file or remote object.

func (*Mixed) Open

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

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

func (*Mixed) Remove

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

Remove deletes either a local file or remote object.

func (*Mixed) Stat

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

Stat returns information about an object at the specified Location.

type MultiReadHandle

type MultiReadHandle interface {
	io.Closer
	SetOffset(offset int64) error
	NextPart(ctx context.Context, length int64) (ReadHandle, error)
	Info(ctx context.Context) (*ObjectInfo, error)
}

MultiReadHandle allows one to read different sections of something. The offset parameter can be negative to signal that the offset should start that many bytes back from the end. Any negative value for length indicates to read up to the end.

TODO: A negative offset requires a negative length, but there is no reason why that must be so.

type MultiWriteHandle

type MultiWriteHandle interface {
	NextPart(ctx context.Context, length int64) (WriteHandle, error)
	Commit(ctx context.Context) error
	Abort(ctx context.Context) error
}

MultiWriteHandle lets one create multiple sequential WriteHandles for different sections of something.

The returned WriteHandle will error if data is attempted to be written past the provided length. A negative length implies an unknown amount of data, and future calls to NextPart will error.

type ObjectInfo

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

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.Closer
	io.Reader
	Info() ObjectInfo
}

ReadHandle is something that can be read from distinct parts possibly in parallel.

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) Copy added in v1.53.1

func (r *Remote) Copy(ctx context.Context, oldbucket, oldkey, newbucket, newkey string) error

Copy copies object to provided key and bucket.

func (*Remote) Create

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

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

func (*Remote) List

func (r *Remote) List(ctx context.Context, bucket, prefix string, opts *ListOptions) ObjectIterator

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

func (*Remote) Move

func (r *Remote) Move(ctx context.Context, oldbucket, oldkey, newbucket, newkey string) error

Move moves object to provided key and bucket.

func (*Remote) Open

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

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

func (*Remote) Remove

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

Remove deletes the object at the provided key and bucket.

func (*Remote) Stat

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

Stat returns information about an object at the specified key.

type RemoveOptions

type RemoveOptions struct {
	Pending bool
}

RemoveOptions describes options to the Remove command.

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