2014-09-22 19:42:11 +00:00
|
|
|
// Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
|
|
|
|
// All rights reserved. Use of this source code is governed by an MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package protocol
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"code.google.com/p/go.text/unicode/norm"
|
|
|
|
)
|
|
|
|
|
|
|
|
type wireFormatConnection struct {
|
|
|
|
next Connection
|
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
func (c wireFormatConnection) ID() DeviceID {
|
2014-09-22 19:42:11 +00:00
|
|
|
return c.next.ID()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) Name() string {
|
|
|
|
return c.next.Name()
|
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
func (c wireFormatConnection) Index(folder string, fs []FileInfo) error {
|
2014-09-22 19:42:11 +00: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))
|
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
return c.next.Index(folder, myFs)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
func (c wireFormatConnection) IndexUpdate(folder string, fs []FileInfo) error {
|
2014-09-22 19:42:11 +00: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))
|
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
return c.next.IndexUpdate(folder, myFs)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2014-09-28 11:00:38 +00:00
|
|
|
func (c wireFormatConnection) Request(folder, name string, offset int64, size int) ([]byte, error) {
|
2014-09-22 19:42:11 +00:00
|
|
|
name = norm.NFC.String(filepath.ToSlash(name))
|
2014-09-28 11:00:38 +00:00
|
|
|
return c.next.Request(folder, name, offset, size)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) ClusterConfig(config ClusterConfigMessage) {
|
|
|
|
c.next.ClusterConfig(config)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c wireFormatConnection) Statistics() Statistics {
|
|
|
|
return c.next.Statistics()
|
|
|
|
}
|