Skip to content

Find, verify, and analyze leaked credentials

Adding new function SetProgressOngoing to be used when the source does not yet know how many items it is scanning and does not want to display a percentage complete. (#1802)

āh̳̕mͭͭͨͩ̐e̘ͬ́͋ͬ̊̓͂d62b21955022c
diff --git a/pkg/sources/sources.go b/pkg/sources/sources.go
index a87d7daa6..eb0dfbe09 100644
--- a/pkg/sources/sources.go
+++ b/pkg/sources/sources.go
@@ -277,6 +277,9 @@ type Validator interface {
// scope should be the len(scopedItems)
// message is the public facing user information about the current progress
// encodedResumeInfo is an optional string representing any information necessary to resume the job if interrupted
+//
+// NOTE: SetProgressOngoing should be used when source does not yet know how many items it is scanning (scope)
+// and does not want to display a percentage complete
func (p *Progress) SetProgressComplete(i, scope int, message, encodedResumeInfo string) {
p.mut.Lock()
defer p.mut.Unlock()
@@ -295,6 +298,23 @@ func (p *Progress) SetProgressComplete(i, scope int, message, encodedResumeInfo
p.PercentComplete = int64((float64(i) / float64(scope)) * 100)
}
+// SetProgressOngoing sets information about the current running job based on
+// the highest level objects in the source.
+// message is the public facing user information about the current progress
+// encodedResumeInfo is an optional string representing any information necessary to resume the job if interrupted
+//
+// NOTE: This method should be used over SetProgressComplete when the source does
+// not yet know how many items it is scanning and does not want to display a percentage complete.
+func (p *Progress) SetProgressOngoing(message string, encodedResumeInfo string) {
+ p.mut.Lock()
+ defer p.mut.Unlock()
+
+ p.Message = message
+ p.EncodedResumeInfo = encodedResumeInfo
+ // Explicitly set SectionsRemaining to 0 so the frontend does not display a percent.
+ p.SectionsRemaining = 0
+}
+
// GetProgress gets job completion percentage for metrics reporting.
func (p *Progress) GetProgress() *Progress {
p.mut.Lock()