lib/model, lib/protocol: Remove FileInfoBatch reuse behavior (#9399)

This commit is contained in:
Jakob Borg
2024-02-10 19:16:27 +01:00
committed by GitHub
parent fc8b353011
commit 96c30f8387
4 changed files with 120 additions and 20 deletions
+25 -5
View File
@@ -154,15 +154,35 @@ type RequestResponse interface {
}
type Connection interface {
// Send an index message. The connection will read and marshal the
// parameters asynchronously, so they should not be modified after
// calling Index().
Index(ctx context.Context, folder string, files []FileInfo) error
// Send an index update message. The connection will read and marshal
// the parameters asynchronously, so they should not be modified after
// calling IndexUpdate().
IndexUpdate(ctx context.Context, folder string, files []FileInfo) error
// Send a request message. The connection will read and marshal the
// parameters asynchronously, so they should not be modified after
// calling Request().
Request(ctx context.Context, folder string, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error)
// Send a cluster configuration message. The connection will read and
// marshal the message asynchronously, so it should not be modified
// after calling ClusterConfig().
ClusterConfig(config ClusterConfig)
// Send a download progress message. The connection will read and
// marshal the parameters asynchronously, so they should not be modified
// after calling DownloadProgress().
DownloadProgress(ctx context.Context, folder string, updates []FileDownloadProgressUpdate)
Start()
SetFolderPasswords(passwords map[string]string)
Close(err error)
DeviceID() DeviceID
Index(ctx context.Context, folder string, files []FileInfo) error
IndexUpdate(ctx context.Context, folder string, files []FileInfo) error
Request(ctx context.Context, folder string, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error)
ClusterConfig(config ClusterConfig)
DownloadProgress(ctx context.Context, folder string, updates []FileDownloadProgressUpdate)
Statistics() Statistics
Closed() <-chan struct{}
ConnectionInfo
+4 -10
View File
@@ -14,25 +14,19 @@ type wireFormatConnection struct {
}
func (c wireFormatConnection) Index(ctx context.Context, folder string, fs []FileInfo) error {
var myFs = make([]FileInfo, len(fs))
copy(myFs, fs)
for i := range fs {
myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
}
return c.Connection.Index(ctx, folder, myFs)
return c.Connection.Index(ctx, folder, fs)
}
func (c wireFormatConnection) IndexUpdate(ctx context.Context, folder string, fs []FileInfo) error {
var myFs = make([]FileInfo, len(fs))
copy(myFs, fs)
for i := range fs {
myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
}
return c.Connection.IndexUpdate(ctx, folder, myFs)
return c.Connection.IndexUpdate(ctx, folder, fs)
}
func (c wireFormatConnection) Request(ctx context.Context, folder string, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {