Files
syncthing/lib/protocol/wireformat.go
T

40 lines
1.0 KiB
Go
Raw Normal View History

// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
2014-09-22 21:42:11 +02:00
package protocol
import (
"context"
2014-09-22 21:42:11 +02:00
"path/filepath"
"golang.org/x/text/unicode/norm"
2014-09-22 21:42:11 +02:00
)
type wireFormatConnection struct {
Connection
2014-09-22 21:42:11 +02:00
}
func (c wireFormatConnection) Index(ctx context.Context, idx *Index) error {
for i := range idx.Files {
idx.Files[i].Name = norm.NFC.String(filepath.ToSlash(idx.Files[i].Name))
2014-09-22 21:42:11 +02:00
}
return c.Connection.Index(ctx, idx)
2014-09-22 21:42:11 +02:00
}
func (c wireFormatConnection) IndexUpdate(ctx context.Context, idxUp *IndexUpdate) error {
for i := range idxUp.Files {
idxUp.Files[i].Name = norm.NFC.String(filepath.ToSlash(idxUp.Files[i].Name))
2014-09-22 21:42:11 +02:00
}
return c.Connection.IndexUpdate(ctx, idxUp)
2014-09-22 21:42:11 +02:00
}
func (c wireFormatConnection) Request(ctx context.Context, req *Request) ([]byte, error) {
req.Name = norm.NFC.String(filepath.ToSlash(req.Name))
return c.Connection.Request(ctx, req)
2014-09-22 21:42:11 +02:00
}