aboutsummaryrefslogtreecommitdiff
path: root/steam/status.go
diff options
context:
space:
mode:
Diffstat (limited to 'steam/status.go')
-rw-r--r--steam/status.go27
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()