summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2015-12-18 02:40:42 (GMT)
committerChristian Pointner <equinox@helsinki.at>2015-12-18 02:40:42 (GMT)
commit16f3a42d4872dfa3d167ccf760f91d624eee312c (patch)
tree79db3f5bb9445e28d749458b288ebd26d93e9d4f
parent21027f52089faf514ecd2c5c1e8bfa4c5f8fe8d3 (diff)
added check for existence of requested session
-rw-r--r--session.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/session.go b/session.go
index 37a4b54..219c233 100644
--- a/session.go
+++ b/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
}