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
- Variables
- func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error)
- func CheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)
- func Color(style string, s string) string
- func Concat[S ~[]E, E any](ss ...S) S
- func CryptCheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)
- func DownloadCheckFn(ctx context.Context, a, b fs.Object) (differ bool, noHash bool, err error)
- func FsPathIfAny(x fs.DirEntry) string
- func ID(o fs.Object) string
- func ReverseCryptCheckFn(ctx context.Context, dst, src fs.Object) (differ bool, noHash bool, err error)
- func SuffixName(ctx context.Context, remote, suffix string) string
- func WhichCheck(ctx context.Context, opt *operations.CheckOpt) *operations.CheckOpt
- func WhichEqual(ctx context.Context, src, dst fs.Object, Fsrc, Fdst fs.Fs) bool
- func WriteResults(ctx context.Context, sigil operations.Sigil, src, dst fs.DirEntry, err error)
- type CheckSyncMode
- type CompareOpt
- type ConflictLoserAction
- type Options
- type Prefer
- type Results
- type ResultsSlice
- type TestFunc
Constants ¶
const ( DefaultMaxDelete int = 50 DefaultCheckFilename string = "RCLONE_TEST" )
Default values
const ListingHeader = "# bisync listing v1 from"
ListingHeader defines first line of a listing
Variables ¶
var Colors bool
Colors controls whether terminal colors are enabled
var ConflictLoserList = Opt.ConflictLoser.Help()
ConflictLoserList is a list of --conflict-loser flag choices used in the help
var ConflictResolveList = Opt.ConflictResolve.Help()
ConflictResolveList is a list of --conflict-resolve flag choices used in the help
var DefaultWorkdir = filepath.Join(config.GetCacheDir(), "bisync")
DefaultWorkdir is default working directory
var ErrBisyncAborted = errors.New("bisync aborted")
ErrBisyncAborted signals that bisync is aborted and forces exit code 2
var (
TZ = time.UTC
)
TZ defines time zone used in listings
Functions ¶
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
CryptCheckFn is a slightly modified version of CryptCheck
func DownloadCheckFn ¶ added in v1.66.0
DownloadCheckFn is a slightly modified version of Check with --download
func FsPathIfAny ¶ added in v1.66.0
FsPathIfAny handles type assertions and returns a formatted bilib.FsPath if valid, otherwise ""
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
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
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
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
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
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 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
ReadResults decodes the JSON data from WriteResults
type ResultsSlice ¶ added in v1.66.0
type ResultsSlice []Results
ResultsSlice is a slice of Results (obviously)