@cryptotaxi247 / kubo / commits / 306c7e2e7

doc(fsrepo)

Brian Tiger Chow committed Jan 12, 2015 at 18:21 UTC 306c7e2e7bb32be71de2da380cceff0960ce72a5
1 file changed +9 -2
repo/fsrepo/fsrepo.go
+9 -2
@@ -13,12 +13,14 @@ import (
13 debugerror "github.com/jbenet/go-ipfs/util/debugerror"
14 )
15
16 +// FSRepo represents an IPFS FileSystem Repo
17 type FSRepo struct {
18 state state
19 path string
20 config *config.Config
21 }
22
23 +// At returns a handle to an FSRepo at the provided |path|.
24 func At(path string) *FSRepo {
25 return &FSRepo{
26 path: path,
@@ -26,6 +28,7 @@ func At(path string) *FSRepo {
28 }
29 }
30
31 +// Init initializes a new FSRepo at the given path with the provided config.
32 func Init(path string, conf *config.Config) error {
33 if IsInitialized(path) {
34 return nil
@@ -86,6 +89,8 @@ func (r *FSRepo) Open() error {
89 return nil
90 }
91
92 +// Config returns the FSRepo's config. Result is undefined if the Repo is not
93 +// Open.
94 func (r *FSRepo) Config() *config.Config {
95 if r.state != opened {
96 panic(fmt.Sprintln("repo is", r.state))
@@ -93,6 +98,7 @@ func (r *FSRepo) Config() *config.Config {
98 return r.config
99 }
100
101 +// SetConfig updates the FSRepo's config.
102 func (r *FSRepo) SetConfig(conf *config.Config) error {
103 if r.state != opened {
104 panic(fmt.Sprintln("repo is", r.state))
@@ -108,7 +114,7 @@ func (r *FSRepo) SetConfig(conf *config.Config) error {
114 return nil
115 }
116
111 -// GetConfigKey retrieves only the value of a particular key
117 +// GetConfigKey retrieves only the value of a particular key.
118 func (r *FSRepo) GetConfigKey(key string) (interface{}, error) {
119 if r.state != opened {
120 return nil, debugerror.Errorf("repo is %s", r.state)
@@ -124,7 +130,7 @@ func (r *FSRepo) GetConfigKey(key string) (interface{}, error) {
130 return common.MapGetKV(cfg, key)
131 }
132
127 -// SetConfigKey writes the value of a particular key
133 +// SetConfigKey writes the value of a particular key.
134 func (r *FSRepo) SetConfigKey(key string, value interface{}) error {
135 if r.state != opened {
136 return debugerror.Errorf("repo is %s", r.state)
@@ -150,6 +156,7 @@ func (r *FSRepo) SetConfigKey(key string, value interface{}) error {
156 return r.SetConfig(conf)
157 }
158
159 +// Close closes the FSRepo, releasing held resources.
160 func (r *FSRepo) Close() error {
161 if r.state != opened {
162 return debugerror.Errorf("repo is %s", r.state)