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