lib/connections: Trigger dialer when connection gets closed (#7753)

This commit is contained in:
Simon Frei
2021-06-17 13:57:44 +02:00
committed by GitHub
parent aeca1fb575
commit 857caf3637
7 changed files with 231 additions and 68 deletions
+7 -1
View File
@@ -27,14 +27,18 @@ func newFakeConnection(id protocol.DeviceID, model Model) *fakeConnection {
Connection: new(protocolmocks.Connection),
id: id,
model: model,
closed: make(chan struct{}),
}
f.RequestCalls(func(ctx context.Context, folder, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {
return f.fileData[name], nil
})
f.IDReturns(id)
f.CloseCalls(func(err error) {
f.closeOnce.Do(func() {
close(f.closed)
})
model.Closed(id, err)
f.ClosedReturns(true)
f.ClosedReturns(f.closed)
})
return f
}
@@ -47,6 +51,8 @@ type fakeConnection struct {
fileData map[string][]byte
folder string
model Model
closed chan struct{}
closeOnce sync.Once
mut sync.Mutex
}