mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 10:28:49 -07:00
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
// Copyright (C) 2014 The Protocol Authors.
|
|
|
|
package protocol
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
|
|
"golang.org/x/text/unicode/norm"
|
|
)
|
|
|
|
type wireFormatConnection struct {
|
|
Connection
|
|
}
|
|
|
|
func (c wireFormatConnection) Index(ctx context.Context, 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(ctx, folder, myFs)
|
|
}
|
|
|
|
func (c wireFormatConnection) IndexUpdate(ctx context.Context, 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(ctx, folder, myFs)
|
|
}
|
|
|
|
func (c wireFormatConnection) Request(ctx context.Context, folder string, name string, blockNo int, offset int64, size int, hash []byte, weakHash uint32, fromTemporary bool) ([]byte, error) {
|
|
name = norm.NFC.String(filepath.ToSlash(name))
|
|
return c.Connection.Request(ctx, folder, name, blockNo, offset, size, hash, weakHash, fromTemporary)
|
|
}
|