MCPcopy
hub / github.com/rclone/rclone / Bisync

Function Bisync

cmd/bisync/operations.go:71–221  ·  view source on GitHub ↗

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

(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options)

Source from the content-addressed store, hash-verified

69
70// Bisync handles lock file, performs bisync run and checks exit status
71func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
72 opt := *optArg // ensure that input is never changed
73 b := &bisyncRun{
74 fs1: fs1,
75 fs2: fs2,
76 opt: &opt,
77 DebugName: opt.DebugName,
78 }
79
80 if opt.CheckFilename == "" {
81 opt.CheckFilename = DefaultCheckFilename
82 }
83 if opt.Workdir == "" {
84 opt.Workdir = DefaultWorkdir
85 }
86 ci := fs.GetConfig(ctx)
87 opt.OrigBackupDir = ci.BackupDir
88
89 if ci.TerminalColorMode == fs.TerminalColorModeAlways || (ci.TerminalColorMode == fs.TerminalColorModeAuto && !log.Redirected()) {
90 ColorsLock.Lock()
91 Colors = true
92 ColorsLock.Unlock()
93 }
94
95 err = b.setCompareDefaults(ctx)
96 if err != nil {
97 return err
98 }
99
100 b.setResyncDefaults()
101
102 err = b.setResolveDefaults()
103 if err != nil {
104 return err
105 }
106
107 if b.workDir, err = filepath.Abs(opt.Workdir); err != nil {
108 return fmt.Errorf("failed to make workdir absolute: %w", err)
109 }
110 if err = os.MkdirAll(b.workDir, os.ModePerm); err != nil {
111 return fmt.Errorf("failed to create workdir: %w", err)
112 }
113
114 // Produce a unique name for the sync operation
115 b.basePath = bilib.BasePath(ctx, b.workDir, b.fs1, b.fs2)
116 b.listing1 = b.basePath + ".path1.lst"
117 b.listing2 = b.basePath + ".path2.lst"
118 b.newListing1 = b.listing1 + "-new"
119 b.newListing2 = b.listing2 + "-new"
120 b.aliases = bilib.AliasMap{}
121
122 err = b.checkSyntax()
123 if err != nil {
124 return err
125 }
126
127 // Handle lock file
128 err = b.setLockFile()

Callers 3

runBisyncMethod · 0.92
rcBisyncFunction · 0.85
cmd.goFile · 0.85

Calls 15

setCompareDefaultsMethod · 0.95
setResyncDefaultsMethod · 0.95
setResolveDefaultsMethod · 0.95
checkSyntaxMethod · 0.95
setLockFileMethod · 0.95
removeLockFileMethod · 0.95
runLockedMethod · 0.95
GetConfigFunction · 0.92
RedirectedFunction · 0.92
BasePathFunction · 0.92
NewLoggerOptFunction · 0.92
SignalledFunction · 0.92

Tested by 1

runBisyncMethod · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…