Update reset API to reflect new use cases.

/rest/reset clears the entire Syncthing DB and restart the program
/rest/reset&folder=default clears the indexes of the default folder
This commit is contained in:
Lode Hoste
2015-04-03 20:06:03 +02:00
parent 65923b5c20
commit ab287ebf40
5 changed files with 222 additions and 24 deletions

View File

@@ -310,6 +310,19 @@ func (p *syncthingProcess) rescan(folder string) error {
return nil
}
func (p *syncthingProcess) reset(folder string) error {
resp, err := p.post("/rest/reset?folder="+folder, nil)
if err != nil {
return err
}
data, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("Reset %q: status code %d: %s", folder, resp.StatusCode, data)
}
return nil
}
func allDevicesInSync(p []syncthingProcess) error {
for _, device := range p {
if err := device.allPeersInSync(); err != nil {