MCPcopy
hub / github.com/syncthing/syncthing / pull

Method pull

lib/model/folder_sendonly.go:42–91  ·  view source on GitHub ↗

pull checks need for files that only differ by metadata (no changes on disk)

(ctx context.Context)

Source from the content-addressed store, hash-verified

40
41// pull checks need for files that only differ by metadata (no changes on disk)
42func (f *sendOnlyFolder) pull(ctx context.Context) (bool, error) {
43 batch := NewFileInfoBatch(func(files []protocol.FileInfo) error {
44 f.updateLocalsFromPulling(files)
45 return nil
46 })
47
48 for file, err := range itererr.Zip(f.db.AllNeededGlobalFiles(f.folderID, protocol.LocalDeviceID, config.PullOrderAlphabetic, 0, 0)) {
49 if err != nil {
50 return false, err
51 }
52 if err := batch.FlushIfFull(); err != nil {
53 return false, err
54 }
55
56 if f.ignores.Match(file.FileName()).IsIgnored() {
57 file.SetIgnored()
58 batch.Append(file)
59 l.Debugln(f, "Handling ignored file", file)
60 continue
61 }
62
63 curFile, ok, err := f.db.GetDeviceFile(f.folderID, protocol.LocalDeviceID, file.FileName())
64 if err != nil {
65 return false, err
66 }
67 if !ok {
68 if file.IsInvalid() || file.IsDeleted() {
69 // Accept the file for accounting purposes
70 batch.Append(file)
71 }
72 continue
73 }
74
75 if !file.IsEquivalentOptional(curFile, protocol.FileInfoComparison{
76 ModTimeWindow: f.modTimeWindow,
77 IgnorePerms: f.IgnorePerms,
78 IgnoreOwnership: !f.SyncOwnership,
79 IgnoreXattrs: !f.SyncXattrs,
80 }) {
81 continue
82 }
83
84 batch.Append(file)
85 l.Debugln(f, "Merging versions of identical file", file)
86 }
87
88 batch.Flush()
89
90 return true, nil
91}
92
93func (f *sendOnlyFolder) Override() {
94 f.doInSync(f.override)

Callers

nothing calls this directly

Calls 15

FlushIfFullMethod · 0.95
AppendMethod · 0.95
FlushMethod · 0.95
ZipFunction · 0.92
NewFileInfoBatchFunction · 0.85
FileNameMethod · 0.80
SetIgnoredMethod · 0.80
DebuglnMethod · 0.80
IsDeletedMethod · 0.80
IsEquivalentOptionalMethod · 0.80
AllNeededGlobalFilesMethod · 0.65

Tested by

no test coverage detected