swift,hubic: fix paged directory listings

This was caused by rclone adjusting the object names.  If the last
object in the listing page happened to be a directory, rclone would
remove the / which caused the next page to start in the wrong place.
This commit is contained in:
Nick Craig-Wood 2017-07-06 11:31:09 +01:00
parent f0512d1a52
commit ce1b9a7daf

View File

@ -295,10 +295,7 @@ func (f *Fs) listContainerRoot(container, root string, dir string, recurse bool,
object := &objects[i]
isDirectory := false
if !recurse {
if strings.HasSuffix(object.Name, "/") {
isDirectory = true
object.Name = object.Name[:len(object.Name)-1]
}
isDirectory = strings.HasSuffix(object.Name, "/")
}
if !strings.HasPrefix(object.Name, root) {
fs.Logf(f, "Odd name received %q", object.Name)
@ -321,6 +318,7 @@ type addEntryFn func(fs.DirEntry) error
func (f *Fs) list(dir string, recurse bool, fn addEntryFn) error {
return f.listContainerRoot(f.container, f.root, dir, recurse, func(remote string, object *swift.Object, isDirectory bool) (err error) {
if isDirectory {
remote = strings.TrimRight(remote, "/")
d := fs.NewDir(remote, time.Time{}).SetSize(object.Bytes)
err = fn(d)
} else {