(input model.Status, rootInfo *model.EndpointRootStat)
| 355 | } |
| 356 | |
| 357 | func (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 | |
| 396 | func printMem(s string) { |
| 397 | fmt.Println(s) |
no test coverage detected