wireformat.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. // All rights reserved. Use of this source code is governed by an MIT-style
  3. // license that can be found in the LICENSE file.
  4. package protocol
  5. import (
  6. "path/filepath"
  7. "code.google.com/p/go.text/unicode/norm"
  8. )
  9. type wireFormatConnection struct {
  10. next Connection
  11. }
  12. func (c wireFormatConnection) ID() NodeID {
  13. return c.next.ID()
  14. }
  15. func (c wireFormatConnection) Name() string {
  16. return c.next.Name()
  17. }
  18. func (c wireFormatConnection) Index(repo string, fs []FileInfo) error {
  19. var myFs = make([]FileInfo, len(fs))
  20. copy(myFs, fs)
  21. for i := range fs {
  22. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  23. }
  24. return c.next.Index(repo, myFs)
  25. }
  26. func (c wireFormatConnection) IndexUpdate(repo string, fs []FileInfo) error {
  27. var myFs = make([]FileInfo, len(fs))
  28. copy(myFs, fs)
  29. for i := range fs {
  30. myFs[i].Name = norm.NFC.String(filepath.ToSlash(myFs[i].Name))
  31. }
  32. return c.next.IndexUpdate(repo, myFs)
  33. }
  34. func (c wireFormatConnection) Request(repo, name string, offset int64, size int) ([]byte, error) {
  35. name = norm.NFC.String(filepath.ToSlash(name))
  36. return c.next.Request(repo, name, offset, size)
  37. }
  38. func (c wireFormatConnection) ClusterConfig(config ClusterConfigMessage) {
  39. c.next.ClusterConfig(config)
  40. }
  41. func (c wireFormatConnection) Statistics() Statistics {
  42. return c.next.Statistics()
  43. }