syncthing/lib/protocol/wireformat.go

41 lines
1004 B
Go
Raw Normal View History

2015-01-13 05:31:14 -07:00
// Copyright (C) 2014 The Protocol Authors.
2014-09-22 12:42:11 -07:00
package protocol
import (
"path/filepath"
"golang.org/x/text/unicode/norm"
2014-09-22 12:42:11 -07:00
)
type wireFormatConnection struct {
Connection
2014-09-22 12:42:11 -07:00
}
func (c wireFormatConnection) Index(folder string, fs []FileInfo) error {
2014-09-22 12:42:11 -07:00
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)
2014-09-22 12:42:11 -07:00
}
func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo) error {
2014-09-22 12:42:11 -07:00
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)
2014-09-22 12:42:11 -07:00
}
func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {
2014-09-22 12:42:11 -07:00
name = norm.NFC.String(filepath.ToSlash(name))
return c.Connection.Request(folder, name, offset, size, hash, weakHash, fromTemporary)
2014-09-22 12:42:11 -07:00
}