forked from pydio/cells
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
40 lines (32 loc) · 866 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package micro
import (
"github.com/pydio/go-os/config"
)
// wrapper around micro config that rewrites to the source if possible
type writableConfig struct {
config.Config
}
// Sets internal cached value
func (w *writableConfig) Set(val interface{}, path ...string) {
w.Config.Set(val, path...)
b := w.Config.Bytes()
// Setting data in all sources available if we have write access
for _, source := range w.Config.Options().Sources {
sw, ok := source.(Writer)
if ok {
sw.Write(&config.ChangeSet{Data: b})
}
}
}
// Deletes internal cached value
func (w *writableConfig) Del(path ...string) {
w.Config.Del(path...)
b := w.Config.Bytes()
// Setting data in all sources available if we have write access
for _, source := range w.Config.Options().Sources {
sw, ok := source.(Writer)
if ok {
sw.Write(&config.ChangeSet{Data: b})
}
}
}