MCPcopy Create free account
hub / github.com/pydio/cells / monitorDiff

Method monitorDiff

common/sync/task/sync-run.go:315–355  ·  view source on GitHub ↗
(ctx context.Context, diff merger.Diff, rootsInfo map[string]*model.EndpointRootStat)

Source from the content-addressed store, hash-verified

313}
314
315func (s *Sync) monitorDiff(ctx context.Context, diff merger.Diff, rootsInfo map[string]*model.EndpointRootStat) chan bool {
316 indexStatus := make(chan model.Status)
317 done := make(chan interface{})
318 finished := make(chan bool, 1)
319 diff.SetupChannels(indexStatus, done, s.cmd)
320 go func() {
321 defer close(finished)
322 for {
323 select {
324 case status := <-indexStatus:
325 if root, ok := rootsInfo[status.EndpointURI()]; ok {
326 if pgStatus, ok := s.computeIndexProgress(status, root); ok && pgStatus != nil {
327 log.Logger(ctx).Info(pgStatus.String())
328 if s.statuses != nil {
329 s.statuses <- pgStatus
330 }
331 }
332 }
333 case <-done:
334 var totalStrings []string
335 var total int64
336 for uri, root := range rootsInfo {
337 total += root.PgChildren
338 totalStrings = append(totalStrings, fmt.Sprintf("%d on %s", root.PgChildren, uri))
339 }
340 tString := strings.Join(totalStrings, ", ")
341 log.Logger(ctx).Info(fmt.Sprintf("Finished analyze : %d nodes (%s)", total, tString), zap.Any("i", total))
342 if s.statuses != nil {
343 for u := range rootsInfo {
344 s.statuses <- model.NewProcessingStatus("").SetEndpoint(u).SetProgress(0)
345 }
346 s.statuses <- model.NewProcessingStatus(fmt.Sprintf("Analyzed %d nodes (%s)", total, tString))
347 }
348 // close(done)
349 // close(indexStatus)
350 return
351 }
352 }
353 }()
354 return finished
355}
356
357func (s *Sync) computeIndexProgress(input model.Status, rootInfo *model.EndpointRootStat) (out model.Status, emit bool) {
358 if input.Node() == nil {

Callers 4

runUniMethod · 0.95
runBiMethod · 0.95
patchesFromSnapshotMethod · 0.95

Calls 12

computeIndexProgressMethod · 0.95
LoggerFunction · 0.92
NewProcessingStatusFunction · 0.92
makeFunction · 0.85
SetEndpointMethod · 0.80
SetupChannelsMethod · 0.65
EndpointURIMethod · 0.65
InfoMethod · 0.65
StringMethod · 0.65
closeFunction · 0.50
JoinMethod · 0.45
SetProgressMethod · 0.45