dropbox: fix depth 1 listing - fixes #1165

This commit is contained in:
Nick Craig-Wood 2017-02-22 12:48:16 +00:00
parent 73a96dc588
commit 12aa03f5b8

View file

@ -241,8 +241,7 @@ func strip(path, root string) (string, error) {
} else if len(root) == 0 { } else if len(root) == 0 {
root = "/" root = "/"
} }
lowercase := strings.ToLower(path) if !strings.HasPrefix(strings.ToLower(path), strings.ToLower(root)) {
if !strings.HasPrefix(lowercase, root) {
return "", errors.Errorf("path %q is not under root %q", path, root) return "", errors.Errorf("path %q is not under root %q", path, root)
} }
return path[len(root):], nil return path[len(root):], nil
@ -382,7 +381,7 @@ func (f *Fs) listOneLevel(out fs.ListOpts, dir string) {
} }
for i := range dirEntry.Contents { for i := range dirEntry.Contents {
entry := &dirEntry.Contents[i] entry := &dirEntry.Contents[i]
remote, err := strip(entry.Path, root) remote, err := f.stripRoot(entry.Path)
if err != nil { if err != nil {
out.SetError(err) out.SetError(err)
return return