syncer

package
v1.0.1-0...-39f75b5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dir

type Dir int

同步方向:本地→远程,远程→本地。

const (
	LocalToRemote Dir = 1
	RemoteToLocal Dir = 2
)

type Element

type Element[E any] interface {
	Less(than E) bool    //  根据路径排序
	DeepEqual(to E) bool // 修改时间、权限也相同
}

type Op

type Op[S ~[]E, E Element[E]] struct {
	// contains filtered or unexported fields
}

func (Op[S, E]) Apply

func (op Op[S, E]) Apply(s *Syncer[S, E])

type Option

type Option[S ~[]E, E Element[E]] interface {
	Apply(*Syncer[S, E])
}

func WithCopyLocalToRemote

func WithCopyLocalToRemote[S ~[]E, E Element[E]](fn func(e E) error) Option[S, E]

func WithCopyRemoteToLocal

func WithCopyRemoteToLocal[S ~[]E, E Element[E]](fn func(e E) error) Option[S, E]

func WithDeleteLocal

func WithDeleteLocal[S ~[]E, E Element[E]](fn func(e E) error) Option[S, E]

func WithDeleteRemote

func WithDeleteRemote[S ~[]E, E Element[E]](fn func(e E) error) Option[S, E]

type Syncer

type Syncer[S ~[]E, E Element[E]] struct {
	// contains filtered or unexported fields
}

对象同步。 用于文件本地、远程列表同步。

func New

func New[S ~[]E, E Element[E]](options ...Option[S, E]) *Syncer[S, E]

func (*Syncer[S, E]) Sync

func (s *Syncer[S, E]) Sync(locals S, remotes S, dir Dir) error

Jump to

Keyboard shortcuts

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