MCPcopy
hub / github.com/rclone/rclone / resync

Method resync

cmd/bisync/resync.go:43–176  ·  view source on GitHub ↗

resync implements the --resync mode. It will generate path1 and path2 listings, copy any unique files to the opposite path, and resolve any differing files according to the --resync-mode.

(fctx context.Context)

Source from the content-addressed store, hash-verified

41// copy any unique files to the opposite path,
42// and resolve any differing files according to the --resync-mode.
43func (b *bisyncRun) resync(fctx context.Context) (err error) {
44 fs.Infof(nil, "Copying Path2 files to Path1")
45
46 // Save blank filelists (will be filled from sync results)
47 ls1 := newFileList()
48 ls2 := newFileList()
49 err = ls1.save(b.newListing1)
50 if err != nil {
51 b.handleErr(ls1, "error saving ls1 from resync", err, true, true)
52 b.abort = true
53 }
54 err = ls2.save(b.newListing2)
55 if err != nil {
56 b.handleErr(ls2, "error saving ls2 from resync", err, true, true)
57 b.abort = true
58 }
59
60 // Check access health on the Path1 and Path2 filesystems
61 // enforce even though this is --resync
62 if b.opt.CheckAccess {
63 fs.Infof(nil, "Checking access health")
64
65 filesNow1, filesNow2, err := b.findCheckFiles(fctx)
66 if err != nil {
67 b.critical = true
68 b.retryable = true
69 return err
70 }
71
72 ds1 := &deltaSet{
73 checkFiles: bilib.Names{},
74 }
75
76 ds2 := &deltaSet{
77 checkFiles: bilib.Names{},
78 }
79
80 for _, file := range filesNow1.list {
81 if filepath.Base(file) == b.opt.CheckFilename {
82 ds1.checkFiles.Add(file)
83 }
84 }
85
86 for _, file := range filesNow2.list {
87 if filepath.Base(file) == b.opt.CheckFilename {
88 ds2.checkFiles.Add(file)
89 }
90 }
91
92 err = b.checkAccess(ds1.checkFiles, ds2.checkFiles)
93 if err != nil {
94 b.critical = true
95 b.retryable = true
96 return err
97 }
98 }
99
100 var results2to1 []Results

Callers 1

runLockedMethod · 0.95

Calls 15

handleErrMethod · 0.95
findCheckFilesMethod · 0.95
checkAccessMethod · 0.95
indentMethod · 0.95
setResyncConfigMethod · 0.95
setBackupDirMethod · 0.95
resyncDirMethod · 0.95
saveOldListingsMethod · 0.95
AddMethod · 0.95
modifyListingMethod · 0.95
checkSyncMethod · 0.95

Tested by

no test coverage detected