MCPcopy Index your code
hub / github.com/devspace-sh/devspace / ChangesCount

Method ChangesCount

helper/server/downstream.go:232–263  ·  view source on GitHub ↗

ChangesCount returns the amount of changes on the remote side

(context.Context, *remote.Empty)

Source from the content-addressed store, hash-verified

230
231// ChangesCount returns the amount of changes on the remote side
232func (d *Downstream) ChangesCount(context.Context, *remote.Empty) (*remote.ChangeAmount, error) {
233 newState := make(map[string]*remote.Change)
234 throttle := time.Duration(d.options.Throttle) * time.Millisecond
235
236 // Walk through the dir
237 if d.options.Polling {
238 walkDir(d.options.RemotePath, d.options.RemotePath, d.ignoreMatcher, newState, d.options.NoRecursiveWatch, throttle)
239 }
240
241 changeAmount := int64(0)
242 if d.options.Polling {
243 var err error
244 changeAmount, err = streamChanges(d.options.RemotePath, d.watchedFiles, newState, nil, throttle)
245 if err != nil {
246 return nil, errors.Wrap(err, "count changes")
247 }
248 } else {
249 d.changesMutex.Lock()
250 // if rescan is not set we make sure that we say that there
251 // are changes
252 if d.lastRescan == nil {
253 changeAmount = int64(1)
254 } else {
255 changeAmount = int64(len(d.changes))
256 }
257 d.changesMutex.Unlock()
258 }
259
260 return &remote.ChangeAmount{
261 Amount: changeAmount,
262 }, nil
263}
264
265func (d *Downstream) getWatchState() map[string]*remote.Change {
266 d.changesMutex.Lock()

Callers

nothing calls this directly

Calls 4

walkDirFunction · 0.85
streamChangesFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected