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
|
|
|
}
|
|
|
|
|
2019-11-25 10:07:36 +00:00
|
|
|
func (c wireFormatConnection) Index(ctx context.Context, folder string, fs []FileInfo) error {
|
2014-09-22 19:42:11 +00:00
|
|
|
for i := range fs {
|
2024-02-10 18:16:27 +00:00
|
|
|
fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-02-10 18:16:27 +00:00
|
|
|
return c.Connection.Index(ctx, folder, fs)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 10:07:36 +00:00
|
|
|
func (c wireFormatConnection) IndexUpdate(ctx context.Context, folder string, fs []FileInfo) error {
|
2014-09-22 19:42:11 +00:00
|
|
|
for i := range fs {
|
2024-02-10 18:16:27 +00:00
|
|
|
fs[i].Name = norm.NFC.String(filepath.ToSlash(fs[i].Name))
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2024-02-10 18:16:27 +00:00
|
|
|
return c.Connection.IndexUpdate(ctx, folder, fs)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|
|
|
|
|
2020-11-09 14:33:32 +00:00
|
|
|
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) {
|
2014-09-22 19:42:11 +00:00
|
|
|
name = norm.NFC.String(filepath.ToSlash(name))
|
2020-11-09 14:33:32 +00:00
|
|
|
return c.Connection.Request(ctx, folder, name, blockNo, offset, size, hash, weakHash, fromTemporary)
|
2014-09-22 19:42:11 +00:00
|
|
|
}
|