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

koofr: use lib/encoder

Fabian Möllerb9bd15a8c980
diff --git a/backend/koofr/koofr.go b/backend/koofr/koofr.go
index 774902515..ee161109a 100644
--- a/backend/koofr/koofr.go
+++ b/backend/koofr/koofr.go
@@ -15,12 +15,15 @@ import (
"github.com/rclone/rclone/fs/config/configmap"
"github.com/rclone/rclone/fs/config/configstruct"
"github.com/rclone/rclone/fs/config/obscure"
+ "github.com/rclone/rclone/fs/encodings"
"github.com/rclone/rclone/fs/hash"
httpclient "github.com/koofr/go-httpclient"
koofrclient "github.com/koofr/go-koofrclient"
)
+const enc = encodings.Koofr
+
// Register Fs with rclone
func init() {
fs.Register(&fs.RegInfo{
@@ -242,7 +245,7 @@ func (f *Fs) Hashes() hash.Set {
// fullPath constructs a full, absolute path from a Fs root relative path,
func (f *Fs) fullPath(part string) string {
- return path.Join("/", f.root, part)
+ return enc.FromStandardPath(path.Join("/", f.root, part))
}
// NewFs constructs a new filesystem given a root path and configuration options
@@ -293,7 +296,7 @@ func NewFs(name, root string, m configmap.Mapper) (ff fs.Fs, err error) {
}
return nil, errors.New("Failed to find mount " + opt.MountID)
}
- rootFile, err := f.client.FilesInfo(f.mountID, "/"+f.root)
+ rootFile, err := f.client.FilesInfo(f.mountID, enc.FromStandardPath("/"+f.root))
if err == nil && rootFile.Type != "dir" {
f.root = dir(f.root)
err = fs.ErrorIsFile
@@ -311,13 +314,14 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
}
entries = make([]fs.DirEntry, len(files))
for i, file := range files {
+ remote := path.Join(dir, enc.ToStandardName(file.Name))
if file.Type == "dir" {
- entries[i] = fs.NewDir(path.Join(dir, file.Name), time.Unix(0, 0))
+ entries[i] = fs.NewDir(remote, time.Unix(0, 0))
} else {
entries[i] = &Object{
fs: f,
info: file,
- remote: path.Join(dir, file.Name),
+ remote: remote,
}
}
}
diff --git a/docs/content/koofr.md b/docs/content/koofr.md
index 7e024d1da..7990745f7 100644
--- a/docs/content/koofr.md
+++ b/docs/content/koofr.md
@@ -86,6 +86,18 @@ To copy a local directory to an Koofr directory called backup
rclone copy /home/source remote:backup
+#### Restricted filename characters
+
+In addition to the [default restricted characters set](/overview/#restricted-characters)
+the following characters are also replaced:
+
+| Character | Value | Replacement |
+| --------- |:-----:|:-----------:|
+| \ | 0x5C | \ |
+
+Invalid UTF-8 bytes will also be [replaced](/overview/#invalid-utf8),
+as they can't be used in XML strings.
+
<!--- autogenerated options start - DO NOT EDIT, instead edit fs.RegInfo in backend/koofr/koofr.go then run make backenddocs -->
### Standard Options