mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 15:20:56 +00:00
fa0101bd60
This changes the BEP protocol to use protocol buffer serialization instead of XDR, and therefore also the database format. The local discovery protocol is also updated to be protocol buffer format. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3276 LGTM: AudriusButkevicius
41 lines
977 B
Go
41 lines
977 B
Go
// Copyright (C) 2014 The Protocol Authors.
|
|
|
|
package protocol
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"golang.org/x/text/unicode/norm"
|
|
)
|
|
|
|
type wireFormatConnection struct {
|
|
Connection
|
|
}
|
|
|
|
func (c wireFormatConnection) Index(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))
|
|
}
|
|
|
|
return c.Connection.Index(folder, myFs)
|
|
}
|
|
|
|
func (c wireFormatConnection) IndexUpdate(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))
|
|
}
|
|
|
|
return c.Connection.IndexUpdate(folder, myFs)
|
|
}
|
|
|
|
func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, fromTemporary bool) ([]byte, error) {
|
|
name = norm.NFC.String(filepath.ToSlash(name))
|
|
return c.Connection.Request(folder, name, offset, size, hash, fromTemporary)
|
|
}
|