diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-09 21:11:52 -0400 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2021-08-09 21:12:03 -0400 |
| commit | 9d5d130038ed90564c3acfb2fd2ff64e3d7b0bd9 (patch) | |
| tree | a95d63e240f0b63ffa4ff2ad3571fa45165b5708 /steam/status.go | |
| parent | c202f2eca32e1ab2e313417168351df1c58ee062 (diff) | |
| download | steam-export-9d5d130038ed90564c3acfb2fd2ff64e3d7b0bd9.tar.gz steam-export-9d5d130038ed90564c3acfb2fd2ff64e3d7b0bd9.tar.xz | |
Fix up cli. Continue fixing up the library and web app. Initial API spec
Diffstat (limited to 'steam/status.go')
| -rw-r--r-- | steam/status.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/steam/status.go b/steam/status.go index 9d70655..9ebf20f 100644 --- a/steam/status.go +++ b/steam/status.go @@ -42,7 +42,7 @@ type Job struct { func (j Job) MarshalJSON() ([]byte, error) { return json.Marshal( struct { - Action string `json:"action"` + Action string `json:"Action"` Target *Game `json:"Target"` Running bool `json:"Running"` Start *time.Time `json:"Start"` @@ -80,7 +80,7 @@ func (j *Job) Target() *Game { return j.target } -// IsRunning returns true if the job is currently running, otherwise false +// IsRunning returns true if a job is currently running, otherwise false func (j *Job) IsRunning() bool { j.m.Lock() defer j.m.Unlock() @@ -233,6 +233,29 @@ func (jobs *Jobs) scan() { jobs.running = running } +// otherThanCurrent will return true if there's another job running on the +// game specified. It's the caller's responsibility to check that the provided +// job has a game of not nil, otherwise a panic will occur +func (jobs *Jobs) otherThanCurrent(j *Job) bool { + for _, job := range jobs.GetRunningJobs() { + if job == j { + continue + } + + g := job.Target() + + if g == nil { + continue + } + + if g.Name == j.Target().Name { + return true + } + } + + return false +} + // Running returns true if any job is currently running, otherwise false func (jobs *Jobs) Running() bool { jobs.scan() |
