From 7c01bbddf8a7ccde05554633b0165f3711d9fdc4 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 1 May 2016 09:53:40 +0100 Subject: [PATCH] Normalise path names for OSX local filesystem Fixes #194 Fixes #451 Fixes #463 --- local/local.go | 1 + local/normalise_darwin.go | 12 ++++++++++++ local/normalise_other.go | 8 ++++++++ 3 files changed, 21 insertions(+) create mode 100644 local/normalise_darwin.go create mode 100644 local/normalise_other.go diff --git a/local/local.go b/local/local.go index 0d47b7cac..1f1bce996 100644 --- a/local/local.go +++ b/local/local.go @@ -100,6 +100,7 @@ func (f *Fs) String() string { // newFsObject makes a half completed Object func (f *Fs) newFsObject(remote string) *Object { + remote = normString(remote) remote = filepath.ToSlash(remote) dstPath := f.filterPath(filepath.Join(f.root, f.cleanUtf8(remote))) return &Object{ diff --git a/local/normalise_darwin.go b/local/normalise_darwin.go new file mode 100644 index 000000000..04595b64a --- /dev/null +++ b/local/normalise_darwin.go @@ -0,0 +1,12 @@ +// +build darwin + +package local + +import ( + "golang.org/x/text/unicode/norm" +) + +// normString normalises the remote name as some OS X denormalises UTF-8 when storing it to disk +func normString(remote string) string { + return norm.NFC.String(remote) +} diff --git a/local/normalise_other.go b/local/normalise_other.go new file mode 100644 index 000000000..bfb9abc2e --- /dev/null +++ b/local/normalise_other.go @@ -0,0 +1,8 @@ +// +build !darwin + +package local + +// normString normalises the remote name if necessary +func normString(remote string) string { + return remote +}