MCPcopy Index your code
hub / github.com/syncthing/syncthing / Summary

Method Summary

lib/model/folder_summary.go:121–203  ·  view source on GitHub ↗
(folder string)

Source from the content-addressed store, hash-verified

119}
120
121func (c *folderSummaryService) Summary(folder string) (*FolderSummary, error) {
122 res := new(FolderSummary)
123
124 var local, global, need, ro db.Counts
125 var ourSeq int64
126 var remoteSeq map[protocol.DeviceID]int64
127 errs, err := c.model.FolderErrors(folder)
128 if err == nil {
129 global, _ = c.model.GlobalSize(folder)
130 local, _ = c.model.LocalSize(folder, protocol.LocalDeviceID)
131 need, _ = c.model.NeedSize(folder, protocol.LocalDeviceID)
132 ro, _ = c.model.ReceiveOnlySize(folder)
133 ourSeq, _ = c.model.Sequence(folder, protocol.LocalDeviceID)
134 remoteSeq, _ = c.model.RemoteSequences(folder)
135 }
136 // For API backwards compatibility (SyncTrayzor needs it) an empty folder
137 // summary is returned for not running folders, an error might actually be
138 // more appropriate
139 if err != nil && !errors.Is(err, ErrFolderPaused) && !errors.Is(err, ErrFolderNotRunning) {
140 return nil, err
141 }
142
143 res.Errors = len(errs)
144 res.PullErrors = len(errs) // deprecated
145
146 res.Invalid = "" // Deprecated, retains external API for now
147
148 res.GlobalFiles, res.GlobalDirectories, res.GlobalSymlinks, res.GlobalDeleted, res.GlobalBytes, res.GlobalTotalItems = global.Files, global.Directories, global.Symlinks, global.Deleted, global.Bytes, global.TotalItems()
149
150 res.LocalFiles, res.LocalDirectories, res.LocalSymlinks, res.LocalDeleted, res.LocalBytes, res.LocalTotalItems = local.Files, local.Directories, local.Symlinks, local.Deleted, local.Bytes, local.TotalItems()
151
152 fcfg, haveFcfg := c.cfg.Folder(folder)
153
154 if haveFcfg && fcfg.IgnoreDelete {
155 need.Deleted = 0
156 }
157
158 need.Bytes -= c.model.FolderProgressBytesCompleted(folder)
159 // This may happen if we are in progress of pulling files that were
160 // deleted globally after the pull started.
161 if need.Bytes < 0 {
162 need.Bytes = 0
163 }
164 res.NeedFiles, res.NeedDirectories, res.NeedSymlinks, res.NeedDeletes, res.NeedBytes, res.NeedTotalItems = need.Files, need.Directories, need.Symlinks, need.Deleted, need.Bytes, need.TotalItems()
165
166 if haveFcfg && (fcfg.Type == config.FolderTypeReceiveOnly || fcfg.Type == config.FolderTypeReceiveEncrypted) {
167 // Add statistics for things that have changed locally in a receive
168 // only or receive encrypted folder.
169 res.ReceiveOnlyChangedFiles = ro.Files
170 res.ReceiveOnlyChangedDirectories = ro.Directories
171 res.ReceiveOnlyChangedSymlinks = ro.Symlinks
172 res.ReceiveOnlyChangedDeletes = ro.Deleted
173 res.ReceiveOnlyChangedBytes = ro.Bytes
174 res.ReceiveOnlyTotalItems = ro.TotalItems()
175 }
176
177 res.InSyncFiles, res.InSyncBytes = global.Files-need.Files, global.Bytes-need.Bytes
178

Callers 1

sendSummaryMethod · 0.95

Calls 15

TotalItemsMethod · 0.95
FolderErrorsMethod · 0.65
GlobalSizeMethod · 0.65
LocalSizeMethod · 0.65
NeedSizeMethod · 0.65
ReceiveOnlySizeMethod · 0.65
SequenceMethod · 0.65
RemoteSequencesMethod · 0.65
FolderMethod · 0.65
StateMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected