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 (
|
2019-11-19 08:56:53 +00:00
|
|
|
"context"
|
2014-09-22 19:42:11 +00:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2024-08-24 10:45:10 +00: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 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 10:45:10 +00:00
|
|
|
return c.Connection.Index(ctx, idx)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 10:45:10 +00: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 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 10:45:10 +00:00
|
|
|
return c.Connection.IndexUpdate(ctx, idxUp)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-08-24 10:45:10 +00: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 19:42:11 +00:00
|
|
|
}
|