all: Refactor the protocol/model interface a bit (ref #8981) (#9007)

This commit is contained in:
Jakob Borg
2023-07-29 10:24:44 +02:00
committed by GitHub
parent b806026990
commit 9d21b91124
21 changed files with 431 additions and 359 deletions
+4 -4
View File
@@ -32,12 +32,12 @@ func newFakeConnection(id protocol.DeviceID, model Model) *fakeConnection {
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.DeviceIDReturns(id)
f.CloseCalls(func(err error) {
f.closeOnce.Do(func() {
close(f.closed)
})
model.Closed(id, err)
model.Closed(f, err)
f.ClosedReturns(f.closed)
})
return f
@@ -157,7 +157,7 @@ func (f *fakeConnection) sendIndexUpdate() {
for i := range f.files {
toSend[i] = prepareFileInfoForIndex(f.files[i])
}
f.model.IndexUpdate(f.id, f.folder, toSend)
f.model.IndexUpdate(f, f.folder, toSend)
}
func addFakeConn(m *testModel, dev protocol.DeviceID, folderID string) *fakeConnection {
@@ -165,7 +165,7 @@ func addFakeConn(m *testModel, dev protocol.DeviceID, folderID string) *fakeConn
fc.folder = folderID
m.AddConnection(fc, protocol.Hello{})
m.ClusterConfig(dev, protocol.ClusterConfig{
m.ClusterConfig(fc, protocol.ClusterConfig{
Folders: []protocol.Folder{
{
ID: folderID,