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"
|
|
|
|
|
2014-11-29 16:17:00 -07:00
|
|
|
"golang.org/x/text/unicode/norm"
|
2014-09-22 12:42:11 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
type wireFormatConnection struct {
|
|
|
|
next Connection
|
|
|
|
}
|
|
|
|
|
2015-07-09 23:34:54 -07:00
|
|
|
func (c wireFormatConnection) Start() {
|
|
|
|
c.next.Start()
|
|
|
|
}
|
|
|
|
|
2014-09-28 04:00:38 -07:00
|
|
|
func (c wireFormatConnection) ID() DeviceID {
|
2014-09-22 12:42:11 -07:00
|
|
|
return c.next.ID()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) Name() string {
|
|
|
|
return c.next.Name()
|
|
|
|
}
|
|
|
|
|
2015-02-04 15:15:17 -07:00
|
|
|
func (c wireFormatConnection) Index(folder string, fs []FileInfo, flags uint32, options []Option) 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))
|
|
|
|
}
|
|
|
|
|
2015-02-04 15:15:17 -07:00
|
|
|
return c.next.Index(folder, myFs, flags, options)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
2015-02-04 15:15:17 -07:00
|
|
|
func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo, flags uint32, options []Option) 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))
|
|
|
|
}
|
|
|
|
|
2015-02-04 15:15:17 -07:00
|
|
|
return c.next.IndexUpdate(folder, myFs, flags, options)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
2015-01-24 14:56:12 -07:00
|
|
|
func (c wireFormatConnection) Request(folder, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error) {
|
2014-09-22 12:42:11 -07:00
|
|
|
name = norm.NFC.String(filepath.ToSlash(name))
|
2015-01-24 14:56:12 -07:00
|
|
|
return c.next.Request(folder, name, offset, size, hash, flags, options)
|
2014-09-22 12:42:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) ClusterConfig(config ClusterConfigMessage) {
|
|
|
|
c.next.ClusterConfig(config)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) Statistics() Statistics {
|
|
|
|
return c.next.Statistics()
|
|
|
|
}
|