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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package config
import (
"errors"
"os"
"path/filepath"
"git.sr.ht/~rjarry/aerc/lib/log"
)
type reloadStore struct {
binds string
conf string
}
var rlst reloadStore
func SetBindsFilename(fn string) {
log.Debugf("reloader: set binds file: %s", fn)
rlst.binds = fn
}
func SetConfFilename(fn string) {
log.Debugf("reloader: set conf file: %s", fn)
rlst.conf = fn
}
func ReloadBinds() (string, error) {
f := rlst.binds
if !exists(f) {
return f, os.ErrNotExist
}
log.Debugf("reload binds file: %s", f)
Binds = defaultBindsConfig()
return f, parseBindsFromFile(filepath.Dir(f), f)
}
func ReloadConf() (string, error) {
f := rlst.conf
if !exists(f) {
return f, os.ErrNotExist
}
log.Debugf("reload conf file: %s", f)
General = new(GeneralConfig)
Filters = nil
Compose = new(ComposeConfig)
Converters = make(map[string]string)
Viewer = new(ViewerConfig)
Statusline = new(StatuslineConfig)
Openers = nil
Hooks = HooksConfig{}
Ui = defaultUIConfig()
Templates = new(TemplateConfig)
return f, parseConf(f)
}
func ReloadAccounts() error {
return errors.New("not implemented")
}
func exists(fn string) bool {
if _, err := os.Stat(fn); errors.Is(err, os.ErrNotExist) {
return false
}
return true
}
|