cloudfs

package
v0.1.13-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultListCacheTTL = 5 * time.Second

Variables

View Source
var (
	ErrNotFound        = errors.New("cloudfs: not found")
	ErrNotDirectory    = errors.New("cloudfs: not a directory")
	ErrAlreadyExists   = errors.New("cloudfs: already exists")
	ErrInvalidPath     = errors.New("cloudfs: invalid path")
	ErrInvalidName     = errors.New("cloudfs: invalid name")
	ErrAmbiguousPath   = errors.New("cloudfs: ambiguous path")
	ErrUnsupported     = errors.New("cloudfs: unsupported operation")
	ErrRateLimited     = errors.New("cloudfs: rate limited")
	ErrProviderFailure = errors.New("cloudfs: provider failure")
)

Functions

This section is empty.

Types

type CooldownLimiter

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

func NewCooldownLimiter

func NewCooldownLimiter(min, max time.Duration) *CooldownLimiter

func (*CooldownLimiter) Wait

func (l *CooldownLimiter) Wait(ctx context.Context) error

type Copier

type Copier interface {
	Copy(ctx context.Context, targetDirID, entryID string) error
}

type Driver

type Driver interface {
	Reader
	Mkdirer
	Renamer
	Mover
	Copier
	Remover
}

Driver is the aggregate facade combining all capability interfaces.

func NewRateLimitedDriver

func NewRateLimitedDriver(next Driver, limiter Limiter) Driver

type Entry

type Entry struct {
	ID       string
	ParentID string
	Name     string
	Type     EntryType
	Size     int64
	PickCode string
}

func (Entry) IsDir

func (e Entry) IsDir() bool

type EntryType

type EntryType string
const (
	EntryTypeFile      EntryType = "file"
	EntryTypeDirectory EntryType = "directory"
)

type FlattenMove

type FlattenMove struct {
	Source Entry
}

FlattenMove describes one future move from a nested path into the target dir.

type FlattenOptions

type FlattenOptions struct {
	DryRun        bool
	KeepEmptyDirs bool
}

FlattenOptions controls future flatten execution behaviour.

type FlattenResult

type FlattenResult struct {
	Target          Entry
	PlannedMoves    []FlattenMove
	PlannedRemovals []Entry
	Moved           []Entry
	RemovedDirs     []Entry
}

FlattenResult is the long-term result model for the flatten composite command.

type Limiter

type Limiter interface {
	Wait(ctx context.Context) error
}

type Mkdirer

type Mkdirer interface {
	Mkdir(ctx context.Context, parentID, name string) (Entry, error)
}

type Mover

type Mover interface {
	Move(ctx context.Context, targetDirID, entryID string) (Entry, error)
}

type RateLimitedDriver

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

func (*RateLimitedDriver) Copy

func (d *RateLimitedDriver) Copy(ctx context.Context, targetDirID, entryID string) error

func (*RateLimitedDriver) Delete

func (d *RateLimitedDriver) Delete(ctx context.Context, entryID string) error

func (*RateLimitedDriver) List

func (d *RateLimitedDriver) List(ctx context.Context, dirID string) ([]Entry, error)

func (*RateLimitedDriver) Lookup

func (d *RateLimitedDriver) Lookup(ctx context.Context, parentID, name string) (Entry, error)

func (*RateLimitedDriver) Mkdir

func (d *RateLimitedDriver) Mkdir(ctx context.Context, parentID, name string) (Entry, error)

func (*RateLimitedDriver) Move

func (d *RateLimitedDriver) Move(ctx context.Context, targetDirID, entryID string) (Entry, error)

func (*RateLimitedDriver) Provider

func (d *RateLimitedDriver) Provider() string

func (*RateLimitedDriver) Rename

func (d *RateLimitedDriver) Rename(ctx context.Context, entryID, newName string) (Entry, error)

func (*RateLimitedDriver) Root

func (d *RateLimitedDriver) Root(ctx context.Context) (Entry, error)

func (*RateLimitedDriver) Stat

func (d *RateLimitedDriver) Stat(ctx context.Context, entryID string) (Entry, error)

type Reader

type Reader interface {
	Provider() string
	Root(ctx context.Context) (Entry, error)
	Stat(ctx context.Context, entryID string) (Entry, error)
	List(ctx context.Context, dirID string) ([]Entry, error)
	Lookup(ctx context.Context, parentID, name string) (Entry, error)
}

type Remover

type Remover interface {
	Delete(ctx context.Context, entryID string) error
}

type Renamer

type Renamer interface {
	Rename(ctx context.Context, entryID, newName string) (Entry, error)
}

type SearchOptions

type SearchOptions struct {
	FileType           int
	ExtName            string
	IncludeDirectories bool
}

type Searcher

type Searcher interface {
	Search(ctx context.Context, dirID, keyword string, opts SearchOptions) ([]Entry, error)
}

type Session

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

func NewSession

func NewSession(ctx context.Context, driver Driver) (*Session, error)

func (*Session) Cd

func (s *Session) Cd(ctx context.Context, target string) (Entry, error)

func (*Session) Cp

func (s *Session) Cp(ctx context.Context, targetDir string, sources ...string) error

func (*Session) Cwd

func (s *Session) Cwd() Entry

func (*Session) Flatten

func (s *Session) Flatten(ctx context.Context, target string, opts FlattenOptions) (FlattenResult, error)

Flatten expands descendant files into the target directory and optionally removes emptied descendant directories.

func (*Session) ListCacheTTL

func (s *Session) ListCacheTTL() time.Duration

func (*Session) Ls

func (s *Session) Ls(ctx context.Context, target string) ([]Entry, error)

func (*Session) Mkdir

func (s *Session) Mkdir(ctx context.Context, target string) (Entry, error)

func (*Session) Mv

func (s *Session) Mv(ctx context.Context, targetDir string, sources ...string) ([]Entry, error)

func (*Session) Provider

func (s *Session) Provider() string

func (*Session) Pwd

func (s *Session) Pwd() string

func (*Session) Refresh

func (s *Session) Refresh()

func (*Session) Rename

func (s *Session) Rename(ctx context.Context, target, newName string) (Entry, error)

func (*Session) Resolve

func (s *Session) Resolve(ctx context.Context, target string) (Entry, string, error)

func (*Session) Rm

func (s *Session) Rm(ctx context.Context, targets ...string) error

func (*Session) Search

func (s *Session) Search(ctx context.Context, searchRoot, keyword string, opts SearchOptions) ([]Entry, error)

Search resolves searchRoot as a directory and returns provider search results.

func (*Session) SearchMove

func (s *Session) SearchMove(
	ctx context.Context,
	searchRoot, keyword, targetDir string,
	opts SearchOptions,
) ([]Entry, error)

SearchMove searches files under searchRoot and moves matched files into targetDir. It pre-checks basename conflicts in targetDir before applying moves.

func (*Session) SetListCacheTTL

func (s *Session) SetListCacheTTL(ttl time.Duration)

func (*Session) Stat

func (s *Session) Stat(ctx context.Context, target string) (Entry, error)

Jump to

Keyboard shortcuts

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