filesystem

package
v4.4.8-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 31 Imported by: 2

Documentation

Overview

Package file system provides endpoints for reading/writing from/to a local folder

Index

Constants

View Source
const (
	SyncTmpPrefix = ".tmp.write."
)

Variables

View Source
var (
	// EventTypeAll contains the notify events that will cause a put (writer)
	EventTypeAll = []notify.Event{notify.All}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypePut = []notify.Event{notify.Create, notify.Write, notify.Rename}
	// EventTypeCreate contains the notify events that will cause a put (writer)
	EventTypeCreate = []notify.Event{notify.Create}
	// EventTypeWrite contains the notify events that will cause a put (writer)
	EventTypeWrite = []notify.Event{notify.Write}
	// EventTypeRename contains the notify events that will cause a put (writer)
	EventTypeRename = []notify.Event{notify.Rename}
	// EventTypeDelete contains the notify events that will cause a delete (remove)
	EventTypeDelete = []notify.Event{notify.Remove}
	// EventTypeGet contains all notify events
	EventTypeGet []notify.Event // On macOS, FreeBSD, Solaris this is not available.

)

Functions

func PipeChan

func PipeChan(capacity int) (inputCh chan notify.EventInfo, outputCh chan notify.EventInfo)

PipeChan builds a new dynamically sized channel

Types

type Discarder

type Discarder struct {
	bytes.Buffer
}

func (*Discarder) Close

func (d *Discarder) Close() error

type FSClient

type FSClient struct {
	RootPath string
	FS       afero.Fs
	// contains filtered or unexported fields
}

FSClient implementation of an endpoint Implements all Sync interfaces (PathSyncTarget, PathSyncSource, DataSyncTarget and DataSyncSource) Takes a root folder as main parameter Underlying calls to FS are done through Afero.FS virtualization, allowing for mockups and automated testings.

func NewFSClient

func NewFSClient(rootPath string, options model.EndpointOptions) (*FSClient, error)

NewFSClient initiate a FileSystem client and stats the provided root. It returns an error if the folder is not reachable

func (*FSClient) CreateNode

func (c *FSClient) CreateNode(ctx context.Context, node tree.N, updateIfExists bool) (err error)

func (*FSClient) DeleteNode

func (c *FSClient) DeleteNode(ctx context.Context, path string) (err error)

func (*FSClient) ExistingFolders

func (c *FSClient) ExistingFolders(ctx context.Context) (map[string][]tree.N, error)

func (*FSClient) FinishSession

func (c *FSClient) FinishSession(ctx context.Context, sessionUuid string) error

FinishSession forwards session management to underlying snapshot

func (*FSClient) FlushSession

func (c *FSClient) FlushSession(ctx context.Context, sessionUuid string) error

FlushSession forwards session management to underlying snapshot

func (*FSClient) GetEndpointInfo

func (c *FSClient) GetEndpointInfo() model.EndpointInfo

func (*FSClient) GetReaderOn

func (c *FSClient) GetReaderOn(_ context.Context, path string) (out io.ReadCloser, err error)

func (*FSClient) GetWriterOn

func (c *FSClient) GetWriterOn(cancel context.Context, path string, targetSize int64) (out io.WriteCloser, writeDone chan bool, writeErr chan error, err error)

func (*FSClient) LoadNode

func (c *FSClient) LoadNode(ctx context.Context, path string, extendedStats ...bool) (node tree.N, err error)

LoadNode is the Read in CRUD. leaf bools are used to avoid doing an FS.stat if we already know a node to be a leaf. NOTE : is it useful? Examine later.

func (*FSClient) MoveNode

func (c *FSClient) MoveNode(ctx context.Context, oldPath string, newPath string) (err error)

MoveNode move file or folder around.

func (*FSClient) PatchUpdateSnapshot

func (c *FSClient) PatchUpdateSnapshot(ctx context.Context, patch interface{})

PatchUpdateSnapshot applies a patch of Operations on the underlying snapshot, if there is one.

func (*FSClient) SetHidden

func (c *FSClient) SetHidden(relativePath string, hidden bool) error

func (*FSClient) SetRefHashStore

func (c *FSClient) SetRefHashStore(source model.PathSyncSource)

func (*FSClient) SetUpdateSnapshot

func (c *FSClient) SetUpdateSnapshot(target model.PathSyncTarget)

SetUpdateSnapshot attaches a snapshot to this client, that will be updated at the same time that the client processes operations on the filesystem

func (*FSClient) StartSession

func (c *FSClient) StartSession(ctx context.Context, rootNode tree.N, silent bool) (string, error)

StartSession forwards session management to underlying snapshot

func (*FSClient) UpdateFolderUuid

func (c *FSClient) UpdateFolderUuid(ctx context.Context, node tree.N) (tree.N, error)

func (*FSClient) Walk

func (c *FSClient) Walk(ctx context.Context, walkFunc model.WalkNodesFunc, root string, recursive bool) (err error)

func (*FSClient) Watch

func (c *FSClient) Watch(recursivePath string) (*model.WatchObject, error)

Watch watches all fs events on an input path.

type FSEventDebouncer

type FSEventDebouncer struct {
	Input chan model.EventInfo
	// contains filtered or unexported fields
}

func NewFSEventDebouncer

func NewFSEventDebouncer(out chan model.EventInfo, errors chan error, c *FSClient, finished func()) *FSEventDebouncer

type WrapperWriter

type WrapperWriter struct {
	io.WriteCloser
	// contains filtered or unexported fields
}

func (*WrapperWriter) Close

func (w *WrapperWriter) Close() error

Jump to

Keyboard shortcuts

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