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
+10 -10
View File
@@ -13,8 +13,8 @@ type TestModel struct {
hash []byte
weakHash uint32
fromTemporary bool
indexFn func(DeviceID, string, []FileInfo)
ccFn func(DeviceID, ClusterConfig)
indexFn func(string, []FileInfo)
ccFn func(ClusterConfig)
closedCh chan struct{}
closedErr error
}
@@ -25,18 +25,18 @@ func newTestModel() *TestModel {
}
}
func (t *TestModel) Index(deviceID DeviceID, folder string, files []FileInfo) error {
func (t *TestModel) Index(_ Connection, folder string, files []FileInfo) error {
if t.indexFn != nil {
t.indexFn(deviceID, folder, files)
t.indexFn(folder, files)
}
return nil
}
func (*TestModel) IndexUpdate(_ DeviceID, _ string, _ []FileInfo) error {
func (*TestModel) IndexUpdate(Connection, string, []FileInfo) error {
return nil
}
func (t *TestModel) Request(_ DeviceID, folder, name string, _, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) {
func (t *TestModel) Request(_ Connection, folder, name string, _, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) {
t.folder = folder
t.name = name
t.offset = offset
@@ -49,19 +49,19 @@ func (t *TestModel) Request(_ DeviceID, folder, name string, _, size int32, offs
return &fakeRequestResponse{buf}, nil
}
func (t *TestModel) Closed(_ DeviceID, err error) {
func (t *TestModel) Closed(_ Connection, err error) {
t.closedErr = err
close(t.closedCh)
}
func (t *TestModel) ClusterConfig(deviceID DeviceID, config ClusterConfig) error {
func (t *TestModel) ClusterConfig(_ Connection, config ClusterConfig) error {
if t.ccFn != nil {
t.ccFn(deviceID, config)
t.ccFn(config)
}
return nil
}
func (*TestModel) DownloadProgress(DeviceID, string, []FileDownloadProgressUpdate) error {
func (*TestModel) DownloadProgress(Connection, string, []FileDownloadProgressUpdate) error {
return nil
}