list

package
v1.70.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 16 Imported by: 30

Documentation

Overview

Package list contains list functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirSorted

func DirSorted(ctx context.Context, f fs.Fs, includeAll bool, dir string) (entries fs.DirEntries, err error)

DirSorted reads Object and *Dir into entries for the given Fs.

dir is the start directory, "" for root

If includeAll is specified all files will be added, otherwise only files and directories passing the filter will be added.

Files will be returned in sorted order

func DirSortedFn added in v1.70.0

func DirSortedFn(ctx context.Context, f fs.Fs, includeAll bool, dir string, callback fs.ListRCallback, keyFn KeyFn) (err error)

DirSortedFn reads Object and *Dir into entries for the given Fs.

dir is the start directory, "" for root

If includeAll is specified all files will be added, otherwise only files and directories passing the filter will be added.

Files will be returned through callback in sorted order

func SortToChan added in v1.70.0

func SortToChan(out chan<- fs.DirEntry) fs.ListRCallback

SortToChan makes a callback for the Sorter which sends the output to the channel provided.

func WithListP added in v1.70.0

func WithListP(ctx context.Context, dir string, list fs.ListPer) (entries fs.DirEntries, err error)

WithListP implements the List interface with ListP

It should be used in backends which support ListP to implement List.

Types

type Helper added in v1.70.0

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

Helper is used in the implementation of ListR to accumulate DirEntries

func NewHelper added in v1.70.0

func NewHelper(callback fs.ListRCallback) *Helper

NewHelper should be called from ListR with the callback passed in

func (*Helper) Add added in v1.70.0

func (lh *Helper) Add(entry fs.DirEntry) error

Add an entry to the stored entries and send them if there are more than a certain amount

func (*Helper) Flush added in v1.70.0

func (lh *Helper) Flush() error

Flush the stored entries (if any) sending them to the callback

type KeyFn added in v1.70.0

type KeyFn func(entry fs.DirEntry) string

KeyFn turns an entry into a sort key

type NewObjecter added in v1.70.0

type NewObjecter interface {
	// NewObject finds the Object at remote.  If it can't be found
	// it returns the error ErrorObjectNotFound.
	NewObject(ctx context.Context, remote string) (fs.Object, error)
}

NewObjecter is the minimum facilities we need from the fs.Fs passed into NewSorter.

type Sorter added in v1.70.0

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

Sorter implements an efficient mechanism for sorting list entries.

If there are a large number of entries (above `--list-cutoff`), this may be done on disk instead of in memory.

Supply entries with the Add method, call Send at the end to deliver the sorted entries and finalise with CleanUp regardless of whether you called Add or Send.

Sorted entries are delivered to the callback supplied to NewSorter when the Send method is called.

func NewSorter added in v1.70.0

func NewSorter(ctx context.Context, f NewObjecter, callback fs.ListRCallback, keyFn KeyFn) (*Sorter, error)

NewSorter creates a new Sorter with callback for sorted entries to be delivered to. keyFn is used to process each entry to get a key function, if nil then it will just use entry.Remote()

func (*Sorter) Add added in v1.70.0

func (ls *Sorter) Add(entries fs.DirEntries) error

Add entries to the list sorter.

Does not call the callback.

Safe to call from concurrent go routines

func (*Sorter) CleanUp added in v1.70.0

func (ls *Sorter) CleanUp()

CleanUp the Sorter, cleaning up any memory / files.

It is safe and encouraged to call this regardless of whether you called Send or not.

This does not call the callback

func (*Sorter) Send added in v1.70.0

func (ls *Sorter) Send() (err error)

Send the sorted entries to the callback.

Jump to

Keyboard shortcuts

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