Add devices without restart (fixes #2083)
This commit is contained in:
@@ -63,6 +63,10 @@ func NewProcess(addr string) *Process {
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Process) ID() protocol.DeviceID {
|
||||
return p.id
|
||||
}
|
||||
|
||||
// LogTo creates the specified log file and ensures that stdout and stderr
|
||||
// from the Start()ed process is redirected there. Must be called before
|
||||
// Start().
|
||||
@@ -229,6 +233,34 @@ func (p *Process) RescanDelay(folder string, delaySeconds int) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Process) ConfigInSync() (bool, error) {
|
||||
bs, err := p.Get("/rest/system/config/insync")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return bytes.Contains(bs, []byte("true")), nil
|
||||
}
|
||||
|
||||
func (p *Process) GetConfig() (config.Configuration, error) {
|
||||
var cfg config.Configuration
|
||||
bs, err := p.Get("/rest/system/config")
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(bs, &cfg)
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
func (p *Process) PostConfig(cfg config.Configuration) error {
|
||||
buf := new(bytes.Buffer)
|
||||
if err := json.NewEncoder(buf).Encode(cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := p.Post("/rest/system/config", buf)
|
||||
return err
|
||||
}
|
||||
|
||||
func InSync(folder string, ps ...*Process) bool {
|
||||
for _, p := range ps {
|
||||
p.eventMut.Lock()
|
||||
|
||||
Reference in New Issue
Block a user