summaryrefslogtreecommitdiff
path: root/internal/model/scan.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-17 15:25:52 +0300
committerPaul Buetow <paul@buetow.org>2026-05-17 15:25:52 +0300
commit914bd7cd6aa14e839332a98d91c30b19865b0cf2 (patch)
tree02b11537237a204048589e14ed24938b805e42f7 /internal/model/scan.go
parent3b24f0e1be832584d6550e8cc3e5d24329f66f90 (diff)
Restructure repo: move Go server into player-server/
Diffstat (limited to 'internal/model/scan.go')
-rw-r--r--internal/model/scan.go88
1 files changed, 0 insertions, 88 deletions
diff --git a/internal/model/scan.go b/internal/model/scan.go
deleted file mode 100644
index aeec15e..0000000
--- a/internal/model/scan.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package model
-
-import "sync"
-
-// ScanProgress tracks the state of an in-progress or recently completed scan.
-type ScanProgress struct {
- mu sync.RWMutex
- Running bool `json:"running"`
- CurrentSet string `json:"current_set,omitempty"`
- SetsTotal int `json:"sets_total"`
- SetsDone int `json:"sets_done"`
- FilesTotal int `json:"files_total"`
- FilesDone int `json:"files_done"`
- LastError string `json:"last_error,omitempty"`
-}
-
-// Start marks a scan running and resets counters for the given set count.
-func (p *ScanProgress) Start(setsTotal int) {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.Running = true
- p.SetsTotal = setsTotal
- p.SetsDone = 0
- p.FilesTotal = 0
- p.FilesDone = 0
- p.LastError = ""
-}
-
-// SetCurrentSet records the set currently being scanned.
-func (p *ScanProgress) SetCurrentSet(name string) {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.CurrentSet = name
-}
-
-// IncrementFile increments the completed file count.
-func (p *ScanProgress) IncrementFile() {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.FilesDone++
-}
-
-// SetFilesTotal records the number of files to scan.
-func (p *ScanProgress) SetFilesTotal(total int) {
- p.mu.Lock()
- defer p.mu.Unlock()
- 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()
- defer p.mu.Unlock()
- p.SetsDone++
-}
-
-// Done marks the scan complete and records an error message when provided.
-func (p *ScanProgress) Done(err error) {
- p.mu.Lock()
- defer p.mu.Unlock()
- p.Running = false
- p.CurrentSet = ""
- if err != nil {
- p.LastError = err.Error()
- }
-}
-
-// Copy returns a race-safe snapshot of the scan progress.
-func (p *ScanProgress) Copy() ScanProgress {
- p.mu.RLock()
- defer p.mu.RUnlock()
- return ScanProgress{
- Running: p.Running,
- CurrentSet: p.CurrentSet,
- SetsTotal: p.SetsTotal,
- SetsDone: p.SetsDone,
- FilesTotal: p.FilesTotal,
- FilesDone: p.FilesDone,
- LastError: p.LastError,
- }
-}