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
+8 -8
View File
@@ -9,27 +9,27 @@ package protocol
import "golang.org/x/text/unicode/norm"
func makeNative(m Model) Model { return nativeModel{m} }
func makeNative(m contextLessModel) contextLessModel { return nativeModel{m} }
type nativeModel struct {
Model
contextLessModel
}
func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) error {
func (m nativeModel) Index(folder string, files []FileInfo) error {
for i := range files {
files[i].Name = norm.NFD.String(files[i].Name)
}
return m.Model.Index(deviceID, folder, files)
return m.contextLessModel.Index(folder, files)
}
func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) error {
func (m nativeModel) IndexUpdate(folder string, files []FileInfo) error {
for i := range files {
files[i].Name = norm.NFD.String(files[i].Name)
}
return m.Model.IndexUpdate(deviceID, folder, files)
return m.contextLessModel.IndexUpdate(folder, files)
}
func (m nativeModel) Request(deviceID DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) {
func (m nativeModel) Request(folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) {
name = norm.NFD.String(name)
return m.Model.Request(deviceID, folder, name, blockNo, size, offset, hash, weakHash, fromTemporary)
return m.contextLessModel.Request(folder, name, blockNo, size, offset, hash, weakHash, fromTemporary)
}