sync

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const Command = "sync"
View Source
const NotExistingFile = "-"

Variables

View Source
var ErrFileUnknown = errors.New("unknown file")

Functions

func ListFilesFromSyncMap

func ListFilesFromSyncMap(runtime *app.Runtime, sync_map SyncMap)

func Main

func Main(runtime *app.Runtime, args *Args)

func SyncFiles

func SyncFiles(session *rpc.RPC, files SyncMap, source string, target string, orphans contract.Orphans, force bool, dry_run bool, on_progress ProgressHandler, on_make_folder MakeFolderHandler) error

Types

type Args

type Args struct {
	DryRun bool   `arg:"-d,--dry-run" help:"Do a dry run, don't upload, download or delete any files." default:"false"`
	Force  bool   `arg:"-f,--force" help:"Upload without any similarity checks." default:"false"`
	List   bool   `arg:"-l,--list" help:"List matching files." default:"false"`
	Local  bool   `arg:"-o,--local" help:"List matching files from local source only." default:"false"`
	Source string `arg:"-s,--source" help:"Sync all from source to target. If source is a folder, target is also treated as a folder."`
	Target string `arg:"-t,--target" help:"Sync all from source to target."`
}

type MakeFolderHandler

type MakeFolderHandler func(dry_run bool, direction TransferDirection, source string, target string)

type ProgressHandler

type ProgressHandler func(direction TransferDirection, operation TransferOperation, dry_run bool, source string, target string, progress float32)

type SyncFile

type SyncFile struct {
	Status SyncStatus
	Source *contract.File
	Target *contract.File
}

type SyncMap

type SyncMap map[string]*SyncFile

func GetLocalSyncMap

func GetLocalSyncMap(path string, includes []glob.Glob, excludes []glob.Glob) (SyncMap, error)

func GetSyncMap

func GetSyncMap(session *rpc.RPC, source string, target string, includes []glob.Glob, excludes []glob.Glob) (SyncMap, error)

type SyncStatus

type SyncStatus string
const (
	SyncStatus_Local  SyncStatus = "< "
	SyncStatus_Both   SyncStatus = "<>"
	SyncStatus_Orphan SyncStatus = " >"
)

type TransferDirection

type TransferDirection string
const (
	TransferDirection_Upload   TransferDirection = ">"
	TransferDirection_Download TransferDirection = "<"
	TransferDirection_None     TransferDirection = ":"
)

type TransferOperation

type TransferOperation string
const (
	TransferOperation_Handle TransferOperation = "HNDL"
	TransferOperation_Delete TransferOperation = "DELT"
	TransferOperation_Ignore TransferOperation = "IGNR"
	TransferOperation_Skip   TransferOperation = "SKIP"
)

Jump to

Keyboard shortcuts

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