Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

seafile: fix operations on files whose names are not in Unicode NFC form

Fredb2664e513aca
diff --git a/backend/seafile/seafile.go b/backend/seafile/seafile.go
index fbdad6b58..16e4ab4dd 100644
--- a/backend/seafile/seafile.go
+++ b/backend/seafile/seafile.go
@@ -30,6 +30,7 @@ import (
"github.com/rclone/rclone/lib/pacer"
"github.com/rclone/rclone/lib/random"
"github.com/rclone/rclone/lib/rest"
+ "golang.org/x/text/unicode/norm"
)
const (
@@ -1169,7 +1170,11 @@ func (f *Fs) mkLibrary(ctx context.Context, libraryName, password string) error
return nil
}
-// splitPath returns the library name and the full path inside the library
+// splitPath returns the library name and the full path inside the library.
+//
+// The path is returned in NFC: Seafile stores names in NFC whatever form it
+// is given but looks them up byte for byte. Library names are stored verbatim
+// so they are left untouched.
func (f *Fs) splitPath(dir string) (library, folder string) {
library = f.libraryName
folder = dir
@@ -1180,6 +1185,7 @@ func (f *Fs) splitPath(dir string) (library, folder string) {
// Adds the root folder to the path to get a full path
folder = path.Join(f.rootDirectory, folder)
}
+ folder = norm.NFC.String(folder)
return
}
diff --git a/backend/seafile/seafile_internal_test.go b/backend/seafile/seafile_internal_test.go
index c8e3c7410..e35664af7 100644
--- a/backend/seafile/seafile_internal_test.go
+++ b/backend/seafile/seafile_internal_test.go
@@ -10,6 +10,7 @@ import (
"github.com/rclone/rclone/fs/config/obscure"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
+ "golang.org/x/text/unicode/norm"
)
type pathData struct {
@@ -101,6 +102,28 @@ func TestSplitPath(t *testing.T) {
expectedLibrary: "Library",
expectedPath: path.Join("root", "path", "subpath", "to", "file"),
},
+ // paths inside a library are returned in NFC, library names are kept as they are
+ {
+ configLibrary: "Library",
+ configRoot: "",
+ argumentPath: norm.NFD.String("path/to/équivalent.txt"),
+ expectedLibrary: "Library",
+ expectedPath: norm.NFC.String("path/to/équivalent.txt"),
+ },
+ {
+ configLibrary: "Library",
+ configRoot: norm.NFD.String("répertoire"),
+ argumentPath: norm.NFD.String("équivalent.txt"),
+ expectedLibrary: "Library",
+ expectedPath: norm.NFC.String("répertoire/équivalent.txt"),
+ },
+ {
+ configLibrary: "",
+ configRoot: "",
+ argumentPath: norm.NFD.String("Bibliothèque/équivalent.txt"),
+ expectedLibrary: norm.NFD.String("Bibliothèque"),
+ expectedPath: norm.NFC.String("équivalent.txt"),
+ },
}
for _, test := range testData {
fs := &Fs{
diff --git a/docs/content/seafile.md b/docs/content/seafile.md
index 60d5dfb94..83c9d0826 100644
--- a/docs/content/seafile.md
+++ b/docs/content/seafile.md
@@ -259,6 +259,12 @@ the following characters are also replaced:
Invalid UTF-8 bytes will also be [replaced](/overview/#invalid-utf8),
as they can't be used in JSON strings.
+Seafile stores file and directory names in Unicode NFC form whatever form
+they are uploaded in, so rclone normalizes names to NFC before sending them.
+Listings therefore always show NFC names, even for files created with
+decomposed (NFD) names as macOS produces them. Library names are not
+normalized as Seafile keeps them exactly as entered.
+
### Seafile and rclone link
Rclone supports generating share links for non-encrypted libraries only.
diff --git a/docs/data/backends/seafile.yaml b/docs/data/backends/seafile.yaml
index b1d735dbf..88e7ab939 100644
--- a/docs/data/backends/seafile.yaml
+++ b/docs/data/backends/seafile.yaml
@@ -3,7 +3,7 @@ name: Seafile
tier: Tier 3
maintainers: Core
features_score: 3
-integration_tests: Failing
+integration_tests: Passing
data_integrity: Other
performance: Medium
adoption: Some use