es_size

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorSessionNotFound = errors.New("session not found")
)

Functions

func ScanFolder

func ScanFolder(task *TaskScanFolder, ctx Context) error

func ScanSingleFileSystem

func ScanSingleFileSystem(
	log esl.Logger,
	seq eq_sequence.Sequence,
	folder, sum kv_storage.Storage,
	fs es_filesystem.FileSystem,
	path es_filesystem.Path,
	depth int,
	h func(s FolderSize),
) error

Types

type Context

type Context interface {
	QueueIdScanFolder() string

	New(sessionId string, path es_filesystem.Path, stg eq_sequence.Stage, fs es_filesystem.FileSystem, folder, sum kv_storage.Storage, meta interface{}) Session
	StartSession(sessionId string, stg eq_sequence.Stage) error

	Get(sessionId string) (Session, error)

	Log() esl.Logger

	ListEach(depth int, h func(sessionId string, meta interface{}, size FolderSize)) error
}

func New

func New(log esl.Logger, queueIdScanFolder string, folder, sum kv_storage.Storage) Context

type FolderSize

type FolderSize struct {
	Path                  string     `json:"path"`
	Depth                 int        `json:"depth"`
	Size                  int64      `json:"size"`
	NumFile               int64      `json:"num_file"`
	NumFolder             int64      `json:"num_folder"`
	ModTimeEarliest       *time.Time `json:"mod_time_earliest"`
	ModTimeLatest         *time.Time `json:"mod_time_latest"`
	OperationalComplexity int64      `json:"operational_complexity"`
}

func Fold

func Fold(path string, fs es_filesystem.FileSystem, entries []es_filesystem.Entry) (size FolderSize)

func (FolderSize) Add

func (z FolderSize) Add(s FolderSize) FolderSize

Returns new instance of this instance plus given s. But keeps Path and Depth attributes.

type Session

type Session interface {
	// Session Id of this scan
	SessionId() string

	// Logger
	Log() esl.Logger

	// Queue stage
	Stage() eq_sequence.Stage

	// Target file system
	FileSystem() es_filesystem.FileSystem

	// Storage for folder tree (path -> descendant paths)
	Folder() kv_storage.Storage

	// Storage for sum (path -> *FolderSize)
	Sum() kv_storage.Storage

	// List each results. This function must call after stage finish.
	// depth == 0 for the root folder.
	ListEach(depth int, h func(size FolderSize)) error

	// Session metadata
	Metadata() interface{}

	// Open session
	Open() error

	// Enqueue
	Enqueue(path es_filesystem.Path, depth int)
}

type TaskScanFolder

type TaskScanFolder struct {
	SessionId string                 `json:"session_id"`
	Path      es_filesystem.PathData `json:"path"`
	Depth     int                    `json:"depth"`
}

type TaskScanFolderDescendants

type TaskScanFolderDescendants struct {
	Folders []string `json:"folders"`
}

Descendant folder paths

Jump to

Keyboard shortcuts

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