File: nativemodel_darwin.go

package info (click to toggle)
syncthing 1.19.2~ds1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 21,484 kB
  • sloc: javascript: 36,375; sh: 1,804; xml: 1,049; makefile: 67
file content (35 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (C) 2014 The Protocol Authors.

//go:build darwin
// +build darwin

package protocol

// Darwin uses NFD normalization

import "golang.org/x/text/unicode/norm"

func makeNative(m Model) Model { return nativeModel{m} }

type nativeModel struct {
	Model
}

func (m nativeModel) Index(deviceID DeviceID, folder string, files []FileInfo) error {
	for i := range files {
		files[i].Name = norm.NFD.String(files[i].Name)
	}
	return m.Model.Index(deviceID, folder, files)
}

func (m nativeModel) IndexUpdate(deviceID DeviceID, folder string, files []FileInfo) error {
	for i := range files {
		files[i].Name = norm.NFD.String(files[i].Name)
	}
	return m.Model.IndexUpdate(deviceID, folder, files)
}

func (m nativeModel) Request(deviceID DeviceID, folder, name string, blockNo, size int32, offset int64, hash []byte, weakHash uint32, fromTemporary bool) (RequestResponse, error) {
	name = norm.NFD.String(name)
	return m.Model.Request(deviceID, folder, name, blockNo, size, offset, hash, weakHash, fromTemporary)
}