diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-12-18 02:40:42 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-12-18 02:40:42 (GMT) |
commit | d98dee68ba2ce1e0fe663fe06b469fca25205842 (patch) | |
tree | e42cc2a190c5789911383d7a8db8bc68cc63e16a /src | |
parent | a8e3fbd06a614559a2bf470f03a07173406b0740 (diff) |
added check for existence of requested session
Diffstat (limited to 'src')
-rw-r--r-- | src/helsinki.at/rhimport/session.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/helsinki.at/rhimport/session.go b/src/helsinki.at/rhimport/session.go index 37a4b54..219c233 100644 --- a/src/helsinki.at/rhimport/session.go +++ b/src/helsinki.at/rhimport/session.go @@ -138,7 +138,11 @@ func (self *SessionStore) NewSession(ctx ImportContext) (string, error) { } func (self *SessionStore) run(user, id string) (resp sessionRunResponse) { - rhdl.Printf("SessionStore: running session '%s/%s'", user, id) + if _, exists := self.store[user][id]; exists { + rhdl.Printf("SessionStore: running session '%s/%s'", user, id) + } else { + resp.err = fmt.Errorf("SessionStore: session '%s/%s' not found", user, id) + } return } @@ -154,7 +158,11 @@ func (self *SessionStore) Run(user, id string) error { } func (self *SessionStore) addProgressHandler(user, id string, userdata interface{}, handler chan ProgressData) (resp sessionAddProgressHandlerResponse) { - rhdl.Printf("SessionStore: adding progress handler to '%s/%s'", user, id) + if _, exists := self.store[user][id]; exists { + rhdl.Printf("SessionStore: adding progress handler to '%s/%s'", user, id) + } else { + resp.err = fmt.Errorf("SessionStore: session '%s/%s' not found", user, id) + } return } @@ -172,7 +180,11 @@ func (self *SessionStore) AddProgressHandler(user, id string, userdata interface } func (self *SessionStore) addDoneHandler(user, id string, userdata interface{}, handler chan ImportResult) (resp sessionAddDoneHandlerResponse) { - rhdl.Printf("SessionStore: adding done handler to '%s/%s'", user, id) + if _, exists := self.store[user][id]; exists { + rhdl.Printf("SessionStore: adding done handler to '%s/%s'", user, id) + } else { + resp.err = fmt.Errorf("SessionStore: session '%s/%s' not found", user, id) + } return } |