lib/protocol: Further interface refactor (#9396)
This is a symmetric change to #9375 -- where that PR changed the protocol->model interface, this changes the model->protocol one.
This commit is contained in:
@@ -30,8 +30,8 @@ func newFakeConnection(id protocol.DeviceID, model Model) *fakeConnection {
|
||||
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.RequestCalls(func(ctx context.Context, req *protocol.Request) ([]byte, error) {
|
||||
return f.fileData[req.Name], nil
|
||||
})
|
||||
f.DeviceIDReturns(id)
|
||||
f.ConnectionIDReturns(rand.String(16))
|
||||
@@ -60,14 +60,16 @@ type fakeConnection struct {
|
||||
}
|
||||
|
||||
func (f *fakeConnection) setIndexFn(fn func(_ context.Context, folder string, fs []protocol.FileInfo) error) {
|
||||
f.IndexCalls(fn)
|
||||
f.IndexUpdateCalls(fn)
|
||||
f.IndexCalls(func(ctx context.Context, idx *protocol.Index) error { return fn(ctx, idx.Folder, idx.Files) })
|
||||
f.IndexUpdateCalls(func(ctx context.Context, idxUp *protocol.IndexUpdate) error {
|
||||
return fn(ctx, idxUp.Folder, idxUp.Files)
|
||||
})
|
||||
}
|
||||
|
||||
func (f *fakeConnection) DownloadProgress(_ context.Context, folder string, updates []protocol.FileDownloadProgressUpdate) {
|
||||
func (f *fakeConnection) DownloadProgress(_ context.Context, dp *protocol.DownloadProgress) {
|
||||
f.downloadProgressMessages = append(f.downloadProgressMessages, downloadProgressMessage{
|
||||
folder: folder,
|
||||
updates: updates,
|
||||
folder: dp.Folder,
|
||||
updates: dp.Updates,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user