summaryrefslogtreecommitdiff
path: root/internal/model
diff options
context:
space:
mode:
Diffstat (limited to 'internal/model')
-rw-r--r--internal/model/scan.go7
-rw-r--r--internal/model/scan_test.go11
2 files changed, 18 insertions, 0 deletions
diff --git a/internal/model/scan.go b/internal/model/scan.go
index 7fb4e8d..aeec15e 100644
--- a/internal/model/scan.go
+++ b/internal/model/scan.go
@@ -47,6 +47,13 @@ func (p *ScanProgress) SetFilesTotal(total int) {
p.FilesTotal = total
}
+// AddFilesTotal adds to the total number of files discovered during the scan.
+func (p *ScanProgress) AddFilesTotal(total int) {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ p.FilesTotal += total
+}
+
// IncrementSet increments the completed set count.
func (p *ScanProgress) IncrementSet() {
p.mu.Lock()
diff --git a/internal/model/scan_test.go b/internal/model/scan_test.go
index acd1dd1..7d370c3 100644
--- a/internal/model/scan_test.go
+++ b/internal/model/scan_test.go
@@ -50,6 +50,17 @@ func TestScanProgress_SetFilesTotal(t *testing.T) {
}
}
+func TestScanProgress_AddFilesTotal(t *testing.T) {
+ var p ScanProgress
+ p.Start(2)
+ p.AddFilesTotal(10)
+ p.AddFilesTotal(15)
+ cp := p.Copy()
+ if cp.FilesTotal != 25 {
+ t.Errorf("FilesTotal = %d, want 25", cp.FilesTotal)
+ }
+}
+
func TestScanProgress_IncrementFile(t *testing.T) {
var p ScanProgress
p.Start(1)