"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
local: refactor default os encoding out from local backend into shared encoder lib
albertony9a2811f0b2b0
diff --git a/backend/local/encode_darwin.go b/backend/local/encode_darwin.godeleted file mode 100644index e5615b318..000000000--- a/backend/local/encode_darwin.go+++ /dev/null@@ -1,11 +0,0 @@-//+build darwin--package local--import "github.com/rclone/rclone/lib/encoder"--// This is the encoding used by the local backend for macOS-//-// macOS can't store invalid UTF-8, it converts them into %XX encoding-const defaultEnc = (encoder.Base |- encoder.EncodeInvalidUtf8)diff --git a/backend/local/encode_other.go b/backend/local/encode_other.godeleted file mode 100644index 2fcafe84e..000000000--- a/backend/local/encode_other.go+++ /dev/null@@ -1,8 +0,0 @@-//+build !windows,!darwin--package local--import "github.com/rclone/rclone/lib/encoder"--// This is the encoding used by the local backend for non windows platforms-const defaultEnc = encoder.Basediff --git a/backend/local/local.go b/backend/local/local.goindex 85b167442..99c9c6f0f 100644--- a/backend/local/local.go+++ b/backend/local/local.go@@ -195,7 +195,7 @@ enabled, rclone will no longer update the modtime after copying a file.`,Name: config.ConfigEncoding,Help: config.ConfigEncodingHelp,Advanced: true,- Default: defaultEnc,+ Default: encoder.OS,}},}fs.Register(fsi)diff --git a/backend/local/tests_test.go b/backend/local/tests_test.goindex e67c72705..f85ea0f15 100644--- a/backend/local/tests_test.go+++ b/backend/local/tests_test.go@@ -3,6 +3,8 @@ package localimport ("runtime""testing"++ "github.com/rclone/rclone/lib/encoder")// Test Windows character replacements@@ -21,7 +23,7 @@ func TestCleanWindows(t *testing.T) {t.Skipf("windows only")}for _, test := range testsWindows {- got := cleanRootPath(test[0], true, defaultEnc)+ got := cleanRootPath(test[0], true, encoder.OS)expect := test[1]if got != expect {t.Fatalf("got %q, expected %q", got, expect)diff --git a/lib/encoder/os_darwin.go b/lib/encoder/os_darwin.gonew file mode 100644index 000000000..7eb128bb2--- /dev/null+++ b/lib/encoder/os_darwin.go@@ -0,0 +1,9 @@+//+build darwin++package encoder++// OS is the encoding used by the local backend for macOS+//+// macOS can't store invalid UTF-8, it converts them into %XX encoding+const OS = (Base |+ EncodeInvalidUtf8)diff --git a/lib/encoder/os_other.go b/lib/encoder/os_other.gonew file mode 100644index 000000000..32a916fb4--- /dev/null+++ b/lib/encoder/os_other.go@@ -0,0 +1,6 @@+//+build !windows,!darwin++package encoder++// OS is the encoding used by the local backend for non windows platforms+const OS = Basediff --git a/backend/local/encode_windows.go b/lib/encoder/os_windows.gosimilarity index 73%rename from backend/local/encode_windows.gorename to lib/encoder/os_windows.goindex 68e87a914..d06b28243 100644--- a/backend/local/encode_windows.go+++ b/lib/encoder/os_windows.go@@ -1,10 +1,8 @@//+build windows-package local+package encoder-import "github.com/rclone/rclone/lib/encoder"--// This is the encoding used by the local backend for windows platforms+// OS is the encoding used by the local backend for windows platforms//// List of replaced characters:// < (less than) -> '<' // FULLWIDTH LESS-THAN SIGN@@ -24,10 +22,10 @@ import "github.com/rclone/rclone/lib/encoder"// Also encode invalid UTF-8 bytes as Go can't convert them to UTF-16.//// https://docs.microsoft.com/de-de/windows/desktop/FileIO/naming-a-file#naming-conventions-const defaultEnc = (encoder.Base |- encoder.EncodeWin |- encoder.EncodeBackSlash |- encoder.EncodeCtl |- encoder.EncodeRightSpace |- encoder.EncodeRightPeriod |- encoder.EncodeInvalidUtf8)+const OS = (Base |+ EncodeWin |+ EncodeBackSlash |+ EncodeCtl |+ EncodeRightSpace |+ EncodeRightPeriod |+ EncodeInvalidUtf8)