From 6ae7bd7914708e86c3056d6993af880f1b192520 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 27 Jul 2019 19:01:52 +0100 Subject: [PATCH] local: encode invalid UTF-8 on macOS --- backend/local/encode_darwin.go | 9 +++++++++ backend/local/encode_other.go | 2 +- fs/encodings/encodings.go | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 backend/local/encode_darwin.go diff --git a/backend/local/encode_darwin.go b/backend/local/encode_darwin.go new file mode 100644 index 000000000..da3e28c41 --- /dev/null +++ b/backend/local/encode_darwin.go @@ -0,0 +1,9 @@ +//+build darwin + +package local + +import ( + "github.com/rclone/rclone/fs/encodings" +) + +const enc = encodings.LocalMacOS diff --git a/backend/local/encode_other.go b/backend/local/encode_other.go index a91cc24c8..fb59edc56 100644 --- a/backend/local/encode_other.go +++ b/backend/local/encode_other.go @@ -1,4 +1,4 @@ -//+build !windows +//+build !windows,!darwin package local diff --git a/fs/encodings/encodings.go b/fs/encodings/encodings.go index 2fdc0c0ce..546ab11f6 100644 --- a/fs/encodings/encodings.go +++ b/fs/encodings/encodings.go @@ -21,6 +21,13 @@ const Display = encoder.Standard // LocalUnix is the encoding used by the local backend for non windows platforms const LocalUnix = Base +// LocalMacOS is the encoding used by the local backend for macOS +// +// macOS can't store invalid UTF-8, it converts them into %XX encoding +const LocalMacOS = encoder.MultiEncoder( + uint(Base) | + encoder.EncodeInvalidUtf8) + // LocalWindows is the encoding used by the local backend for windows platforms // // List of replaced characters: @@ -267,6 +274,8 @@ func ByName(name string) encoder.Encoder { return LocalWindows case "local-unix", "unix": return LocalUnix + case "local-macos", "macos": + return LocalMacOS case "mega": return Mega case "onedrive": @@ -309,6 +318,7 @@ func Names() []string { "koofr", "local-unix", "local-windows", + "local-macos", "local", "mega", "onedrive",