bisync

package
v1.68.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 43 Imported by: 4

Documentation

Overview

Package bisync implements bisync Copyright (c) 2017-2020 Chris Nelson

Package bisync implements bisync Copyright (c) 2017-2020 Chris Nelson

Package bisync implements bisync Copyright (c) 2017-2020 Chris Nelson

Package bisync implements bisync Copyright (c) 2017-2020 Chris Nelson Contributions to original python version: Hildo G. Jr., e2t, kalemas, silenceleaf

Index

Constants

View Source
const (
	DefaultMaxDelete     int    = 50
	DefaultCheckFilename string = "RCLONE_TEST"
)

Default values

View Source
const ListingHeader = "# bisync listing v1 from"

ListingHeader defines first line of a listing

Variables

View Source
var Colors bool

Colors controls whether terminal colors are enabled

View Source
var ConflictLoserList = Opt.ConflictLoser.Help()

ConflictLoserList is a list of --conflict-loser flag choices used in the help

View Source
var ConflictResolveList = Opt.ConflictResolve.Help()

ConflictResolveList is a list of --conflict-resolve flag choices used in the help

View Source
var DefaultWorkdir = filepath.Join(config.GetCacheDir(), "bisync")

DefaultWorkdir is default working directory

View Source
var ErrBisyncAborted = errors.New("bisync aborted")

ErrBisyncAborted signals that bisync is aborted and forces exit code 2

View Source
var (
	TZ = time.UTC
)

TZ defines time zone used in listings

Functions

func Bisync

func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error)

Bisync handles lock file, performs bisync run and checks exit status

func CheckFn added in v1.66.0

func CheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)

CheckFn is a slightly modified version of Check

func Color added in v1.66.0

func Color(style string, s string) string

Color handles terminal colors for bisync

func Concat added in v1.66.0

func Concat[S ~[]E, E any](ss ...S) S

Concat returns a new slice concatenating the passed in slices.

func CryptCheckFn added in v1.66.0

func CryptCheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)

CryptCheckFn is a slightly modified version of CryptCheck

func DownloadCheckFn added in v1.66.0

func DownloadCheckFn(ctx context.Context, a, b fs.Object) (differ bool, noHash bool, err error)

DownloadCheckFn is a slightly modified version of Check with --download

func FsPathIfAny added in v1.66.0

func FsPathIfAny(x fs.DirEntry) string

FsPathIfAny handles type assertions and returns a formatted bilib.FsPath if valid, otherwise ""

func ID added in v1.66.0

func ID(o fs.Object) string

ID returns the ID of the Object if known, or "" if not

func ReverseCryptCheckFn added in v1.66.0

func ReverseCryptCheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)

ReverseCryptCheckFn is like CryptCheckFn except src and dst are switched result: src is crypt, dst is non-crypt

func SuffixName added in v1.66.0

func SuffixName(ctx context.Context, remote, suffix string) string

SuffixName adds the current --conflict-suffix to the remote, obeying --suffix-keep-extension if set It is a close cousin of operations.SuffixName, but we don't want to use ci.Suffix for this because it might be used for --backup-dir.

func WhichCheck added in v1.66.0

func WhichCheck(ctx context.Context, opt *operations.CheckOpt) *operations.CheckOpt

WhichCheck determines which CheckFn we should use based on the Fs types It is more robust and accurate than Check because it will fallback to CryptCheck or DownloadCheck instead of --size-only! it returns the *operations.CheckOpt with the CheckFn set.

func WhichEqual added in v1.66.0

func WhichEqual(ctx context.Context, src, dst fs.Object, Fsrc, Fdst fs.Fs) bool

WhichEqual is similar to WhichCheck, but checks a single object. Returns true if the objects are equal, false if they differ or if we don't know

func WriteResults added in v1.66.0

func WriteResults(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error)

WriteResults is Bisync's LoggerFn

Types

type CheckSyncMode

type CheckSyncMode int

CheckSyncMode controls when to compare final listings

const (
	CheckSyncTrue  CheckSyncMode = iota // Compare final listings (default)
	CheckSyncFalse                      // Disable comparison of final listings
	CheckSyncOnly                       // Only compare listings from the last run, do not sync
)

CheckSync modes

func (*CheckSyncMode) Set

func (x *CheckSyncMode) Set(s string) error

Set a CheckSync mode from a string

func (CheckSyncMode) String

func (x CheckSyncMode) String() string

func (*CheckSyncMode) Type

func (x *CheckSyncMode) Type() string

Type of the CheckSync value

type CompareOpt added in v1.66.0

type CompareOpt = struct {
	Modtime          bool
	Size             bool
	Checksum         bool
	HashType1        hash.Type
	HashType2        hash.Type
	NoSlowHash       bool
	SlowHashSyncOnly bool
	SlowHashDetected bool
	DownloadHash     bool
}

CompareOpt describes the Compare options in force

type ConflictLoserAction added in v1.66.0

type ConflictLoserAction = fs.Enum[conflictLoserChoices]

ConflictLoserAction describes possible actions to take on the loser of a sync conflict

const (
	ConflictLoserSkip     ConflictLoserAction = iota // Reserved as zero but currently unused
	ConflictLoserNumber                              // file.conflict1, file.conflict2, file.conflict3, etc.
	ConflictLoserPathname                            // file.path1, file.path2
	ConflictLoserDelete                              // delete the loser, keep winner only
)

Supported --conflict-loser actions

type Options

type Options struct {
	Resync                bool   // whether or not this is a resync
	ResyncMode            Prefer // which mode to use for resync
	CheckAccess           bool
	CheckFilename         string
	CheckSync             CheckSyncMode
	CreateEmptySrcDirs    bool
	RemoveEmptyDirs       bool
	MaxDelete             int // percentage from 0 to 100
	Force                 bool
	FiltersFile           string
	Workdir               string
	OrigBackupDir         string
	BackupDir1            string
	BackupDir2            string
	DryRun                bool
	NoCleanup             bool
	SaveQueues            bool // save extra debugging files (test only flag)
	IgnoreListingChecksum bool
	Resilient             bool
	Recover               bool
	TestFn                TestFunc // test-only option, for mocking errors
	Compare               CompareOpt
	CompareFlag           string
	DebugName             string
	MaxLock               time.Duration
	ConflictResolve       Prefer
	ConflictLoser         ConflictLoserAction
	ConflictSuffixFlag    string
	ConflictSuffix1       string
	ConflictSuffix2       string
}

Options keep bisync options

var Opt Options

Opt keeps command line options

type Prefer added in v1.66.0

type Prefer = fs.Enum[preferChoices]

Prefer describes strategies for resolving sync conflicts

const (
	PreferNone Prefer = iota
	PreferPath1
	PreferPath2
	PreferNewer
	PreferOlder
	PreferLarger
	PreferSmaller
)

Supported --conflict-resolve strategies

type Results added in v1.66.0

type Results struct {
	Src      string
	Dst      string
	Name     string
	AltName  string
	Size     int64
	Modtime  time.Time
	Hash     string
	Flags    string
	Sigil    operations.Sigil
	Err      error
	Winner   operations.Winner
	IsWinner bool
	IsSrc    bool
	IsDst    bool
	Origin   string
}

Results represents a pair of synced files, as reported by the LoggerFn Bisync uses this to determine what happened during the sync, and modify the listings accordingly

func ReadResults added in v1.66.0

func ReadResults(results io.Reader) []Results

ReadResults decodes the JSON data from WriteResults

type ResultsSlice added in v1.66.0

type ResultsSlice []Results

ResultsSlice is a slice of Results (obviously)

type TestFunc added in v1.66.0

type TestFunc func()

TestFunc allows mocking errors during tests

Directories

Path Synopsis
Package bilib provides common stuff for bisync and bisync_test
Package bilib provides common stuff for bisync and bisync_test

Jump to

Keyboard shortcuts

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