sync

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int
const (
	UnknownAction Action = iota
	// CreateAction the action of create a file
	CreateAction
	// WriteAction the action of write data to the file
	WriteAction
	// RemoveAction the action of remove the file
	RemoveAction
	// RenameAction the action of rename the file
	RenameAction
	// ChmodAction the action of change the file mode
	ChmodAction
)

func (Action) String

func (action Action) String() string

type Message

type Message struct {
	contract.Status
	contract.FileInfo
	// Action the action of file change
	Action Action `json:"action"`
	// BaseUrl the base url of file server
	BaseUrl string `json:"base_url"`
}

Message a message of the remote file change

type Sync

type Sync interface {
	// Create create the path
	Create(path string) error
	// Write write the data to path
	Write(path string) error
	// Remove remove the path
	Remove(path string) error
	// Rename rename the path
	Rename(path string) error
	// Chmod change the mode of path
	Chmod(path string) error
	// IsDir is a dir the path
	IsDir(path string) (bool, error)
	// SyncOnce sync the path to target once
	SyncOnce(path string) error
	// Source the source file system
	Source() core.VFS
	// Target the target file system
	Target() core.VFS
}

Sync a file sync interface

func NewDiskSync

func NewDiskSync(src, target core.VFS, enableLogicallyDelete bool) (s Sync, err error)

NewDiskSync create a diskSync instance src is source path to read target is target path to write

func NewRemoteClientSync

func NewRemoteClientSync(src, target core.VFS, users []*auth.User, enableLogicallyDelete bool) (Sync, error)

NewRemoteClientSync create an instance of remoteClientSync to receive the file change message and execute it

func NewRemoteServerSync

func NewRemoteServerSync(src, target core.VFS, enableTLS bool, certFile string, keyFile string, users []*auth.User, enableLogicallyDelete bool) (Sync, error)

NewRemoteServerSync create an instance of remoteServerSync execute send file change message

func NewRemoteSync

func NewRemoteSync(src, target core.VFS, enableTLS bool, certFile string, keyFile string, users []*auth.User, enableLogicallyDelete bool) (Sync, error)

NewRemoteSync auto create an instance of remoteServerSync or remoteClientSync according to src and target

func NewSync

func NewSync(src core.VFS, target core.VFS, enableTLS bool, certFile string, keyFile string, users []*auth.User, enableLogicallyDelete bool) (Sync, error)

NewSync auto create an instance of the expected sync according to src and target

Jump to

Keyboard shortcuts

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