filesync

package
v0.0.0-...-7ef1397 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgSync     = "SYNC"
	MsgMd5List  = "MD5LIST"
	MsgTran     = "TRAN"
	MsgTranData = "TRAN-DATA"
	MsgEnd      = "END"
	MsgError    = "ERROR"
)

Variables

View Source
var (
	// TLSEnabled 是否启用TLS加密
	TLSEnabled  bool
	TLSCertFile string
	TLSKeyFile  string
)

Functions

func Md5OfAFile

func Md5OfAFile(f string) (string, error)

func StartFileSyncServer

func StartFileSyncServer(host, port, authKey string)

StartFileSyncServer 启动文件同步服务监听

func Traverse

func Traverse(path string) ([]string, error)

Traverse walk要同步的文件, 生成md5, 并返回列表

func WorkerStartupSync

func WorkerStartupSync(host, port, authKey string)

WorkerStartupSync worker在启动时进行文件同步

Types

type GobConn

type GobConn struct {
	Dec *gob.Decoder
	// contains filtered or unexported fields
}

type Message

type Message struct {
	MgAuthKey  string
	MgType     string //
	MgByte     []byte //
	MgString   string //
	MgStrings  []string
	MgFileMode os.FileMode
	Del        bool // whether should the not exist files in src be deleted.
	Overwrite  bool // whether the conflicted files be
}

Message 文件同步交互消息

type NotifyFile

type NotifyFile struct {
	ChNeedWorkerSync chan string
	// contains filtered or unexported fields
}

func NewNotifyFile

func NewNotifyFile() *NotifyFile

func (*NotifyFile) WatchDir

func (n *NotifyFile) WatchDir(srcPath string)

WatchDir 监控目录中文件的变化

func (*NotifyFile) WatchEvent

func (n *NotifyFile) WatchEvent()

WatchEvent 文件变化事件通知

func (*NotifyFile) WatchFile

func (n *NotifyFile) WatchFile(srcPathFile []string)

WatchFile 监控指定文件的变化

Jump to

Keyboard shortcuts

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