@cryptotaxi247 / kubo / commits / b54c7de48

fix(fsrepo): add guard to ConfigKey methods

Brian Tiger Chow committed Jan 12, 2015 at 18:17 UTC b54c7de48c932944accff57be53219fa4b7f775d
1 file changed +6
repo/fsrepo/fsrepo.go
+6
@@ -110,6 +110,9 @@ func (r *FSRepo) SetConfig(conf *config.Config) error {
110
111 // GetConfigKey retrieves only the value of a particular key
112 func (r *FSRepo) GetConfigKey(key string) (interface{}, error) {
113 + if r.state != opened {
114 + return nil, debugerror.Errorf("repo is %s", r.state)
115 + }
116 filename, err := config.Filename(r.path)
117 if err != nil {
118 return nil, err
@@ -123,6 +126,9 @@ func (r *FSRepo) GetConfigKey(key string) (interface{}, error) {
126
127 // SetConfigKey writes the value of a particular key
128 func (r *FSRepo) SetConfigKey(key string, value interface{}) error {
129 + if r.state != opened {
130 + return debugerror.Errorf("repo is %s", r.state)
131 + }
132 filename, err := config.Filename(r.path)
133 if err != nil {
134 return err