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

jottacloud: fix listing output of remote with special characters

albertonya9d3283d97e1
diff --git a/backend/jottacloud/jottacloud.go b/backend/jottacloud/jottacloud.go
index 62491dea1..5d3838254 100644
--- a/backend/jottacloud/jottacloud.go
+++ b/backend/jottacloud/jottacloud.go
@@ -932,7 +932,7 @@ func (f *Fs) List(ctx context.Context, dir string) (entries fs.DirEntries, err e
return entries, nil
}
-func parseListRStream(ctx context.Context, r io.Reader, trimPrefix string, filesystem *Fs, callback func(fs.DirEntry) error) error {
+func parseListRStream(ctx context.Context, r io.Reader, filesystem *Fs, callback func(fs.DirEntry) error) error {
type stats struct {
Folders int `xml:"folders"`
@@ -968,8 +968,12 @@ func parseListRStream(ctx context.Context, r io.Reader, trimPrefix string, files
})
}
+ // liststream paths are /mountpoint/root/path
+ // so the returned paths should have /mountpoint/root/ trimmed
+ // as the caller is expecting path.
+ pathPrefix := filesystem.opt.Enc.FromStandardPath(path.Join("/", filesystem.opt.Mountpoint, filesystem.root))
trimPathPrefix := func(p string) string {
- p = strings.TrimPrefix(p, trimPrefix)
+ p = strings.TrimPrefix(p, pathPrefix)
p = strings.TrimPrefix(p, "/")
return p
}
@@ -1052,11 +1056,7 @@ func (f *Fs) ListR(ctx context.Context, dir string, callback fs.ListRCallback) (
return shouldRetry(ctx, resp, err)
}
- // liststream paths are /mountpoint/root/path
- // so the returned paths should have /mountpoint/root/ trimmed
- // as the caller is expecting path.
- trimPrefix := path.Join("/", f.opt.Mountpoint, f.root)
- err = parseListRStream(ctx, resp.Body, trimPrefix, f, func(d fs.DirEntry) error {
+ err = parseListRStream(ctx, resp.Body, f, func(d fs.DirEntry) error {
if d.Remote() == dir {
return nil
}