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

Method computeIndexProgress

common/sync/task/sync-run.go:357–394  ·  view source on GitHub ↗
(input model.Status, rootInfo *model.EndpointRootStat)

Source from the content-addressed store, hash-verified

355}
356
357func (s *Sync) computeIndexProgress(input model.Status, rootInfo *model.EndpointRootStat) (out model.Status, emit bool) {
358 if input.Node() == nil {
359 rootInfo.PgChildren++
360 } else if input.Node().IsLeaf() {
361 rootInfo.PgChildren++
362 rootInfo.PgFiles++
363 rootInfo.PgSize += input.Node().GetSize()
364 } else {
365 rootInfo.PgChildren++
366 rootInfo.PgFolders++
367 rootInfo.PgSize += 36
368 }
369 if !rootInfo.HasSizeInfo && !rootInfo.HasChildrenInfo {
370 // Publish every 100 nodes
371 if rootInfo.PgChildren%500 != 0 {
372 return // false
373 } else {
374 return model.NewProcessingStatus(fmt.Sprintf("[%s] Analyzed %d nodes", input.EndpointURI(), rootInfo.PgChildren)).SetEndpoint(input.EndpointURI()), true
375 }
376 }
377 var pg float64
378 if rootInfo.HasSizeInfo && rootInfo.Size > 0 {
379 // Compute progress based on SizeInfo
380 pg = float64(rootInfo.PgSize) / float64(rootInfo.Size)
381 } else {
382 // Compute progress based on ChildrenInfo
383 pg = float64(rootInfo.PgChildren) / float64(rootInfo.Children())
384 }
385 if pg-rootInfo.LastPg > 0.05 {
386 emit = true
387 rootInfo.LastPg = pg
388 output := model.NewProcessingStatus(fmt.Sprintf("[%s] Analyzed %d nodes (%d%%)", input.EndpointURI(), rootInfo.PgChildren, int(math.Floor(pg*100))))
389 output.SetProgress(float32(pg), true)
390 output.SetEndpoint(input.EndpointURI())
391 return output, true
392 }
393 return
394}
395
396func printMem(s string) {
397 fmt.Println(s)

Callers 1

monitorDiffMethod · 0.95

Calls 8

SetEndpointMethod · 0.95
SetProgressMethod · 0.95
NewProcessingStatusFunction · 0.92
ChildrenMethod · 0.80
NodeMethod · 0.65
IsLeafMethod · 0.65
GetSizeMethod · 0.65
EndpointURIMethod · 0.65

Tested by

no test coverage detected