filesystem

package
v3.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: AGPL-3.0 Imports: 29 Imported by: 0

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 (
	// EventTypePut 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}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeCreate = []notify.Event{notify.Create}
	// EventTypePut contains the notify events that will cause a put (writer)
	EventTypeWrite = []notify.Event{notify.Write}
	// EventTypePut 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 the notify events that will cause a get (read)
	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.Node, 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.Node, 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(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.Node, 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.Node, silent bool) (*tree.IndexationSession, error)

StartSession forwards session management to underlying snapshot

func (*FSClient) UpdateFolderUuid

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

func (*FSClient) Walk

func (c *FSClient) Walk(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