diff --git a/lib/rc/rc.go b/lib/rc/rc.go index 446f9103e..7e0fd7fc4 100644 --- a/lib/rc/rc.go +++ b/lib/rc/rc.go @@ -281,6 +281,16 @@ func (p *Process) PostConfig(cfg config.Configuration) error { return err } +func (p *Process) PauseDevice(dev protocol.DeviceID) error { + _, err := p.Post("/rest/system/pause?device="+dev.String(), nil) + return err +} + +func (p *Process) ResumeDevice(dev protocol.DeviceID) error { + _, err := p.Post("/rest/system/resume?device="+dev.String(), nil) + return err +} + func InSync(folder string, ps ...*Process) bool { for _, p := range ps { p.eventMut.Lock() diff --git a/test/conflict_test.go b/test/conflict_test.go index 23001fabc..1091524ca 100644 --- a/test/conflict_test.go +++ b/test/conflict_test.go @@ -80,6 +80,10 @@ func TestConflictsDefault(t *testing.T) { log.Println("Introducing a conflict (simultaneous edit)...") + if err := sender.PauseDevice(receiver.ID()); err != nil { + t.Fatal(err) + } + fd, err = os.OpenFile("s1/testfile.txt", os.O_WRONLY|os.O_APPEND, 0644) if err != nil { t.Fatal(err) @@ -106,6 +110,10 @@ func TestConflictsDefault(t *testing.T) { t.Fatal(err) } + if err := sender.ResumeDevice(receiver.ID()); err != nil { + t.Fatal(err) + } + log.Println("Syncing...") if err := sender.RescanDelay("default", 86400); err != nil { @@ -129,6 +137,10 @@ func TestConflictsDefault(t *testing.T) { log.Println("Introducing a conflict (edit plus delete)...") + if err := sender.PauseDevice(receiver.ID()); err != nil { + t.Fatal(err) + } + err = os.Remove("s1/testfile.txt") if err != nil { t.Fatal(err) @@ -147,6 +159,10 @@ func TestConflictsDefault(t *testing.T) { t.Fatal(err) } + if err := sender.ResumeDevice(receiver.ID()); err != nil { + t.Fatal(err) + } + log.Println("Syncing...") if err := sender.RescanDelay("default", 86400); err != nil {